git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Subject: Re: [PATCH] gitweb: Consolidate escaping/validation of query string
Date: Sun, 24 Sep 2006 14:31:08 +0200	[thread overview]
Message-ID: <ef5tqa$bjd$1@sea.gmane.org> (raw)
In-Reply-To: 20060924113932.11208.33780.stgit@rover

Petr Baudis wrote:

> Consider:
> 
>       http://repo.or.cz/?p=glibc-cvs.git;a=tree;h=2609cb0411389325f4ee2854cc7159756eb0671e;hb=2609cb0411389325f4ee2854cc7159756eb0671e
> 
> (click on the funny =__ify file)
> 
> We ought to handle anything in filenames and I actually see no reason why
> we don't, modulo very little missing escaping that this patch hopefully
> also fixes.
> 
> I have also made esc_param() escape [?=&;]. Not escaping [&;] was downright
> buggy and [?=] just feels better escaped. ;-) YMMV.
> 
> Signed-off-by: Petr Baudis <pasky@suse.cz>

This patch contains a few unrelated changes:
 * changing semantics of esc_param subroutine
 * adding some esc_html where it could be needed
 * removing $file_name and $file_parent validation

About change to esc_param: we need current version of esc_param, perhaps
to be named esc_url to be able to say esc_url($home_link) and soon
esc_url($githelp_url).

About adding esc_html where it could be needed: good change, see
my comments below.

About removing $file_name and $file_parent validation: those parameters
have exactly the same textual restrictions as $project parameter - they
are pathnames.

> @@ -2439,7 +2429,7 @@ sub git_blame2 {
>       if ($ftype !~ "blob") {
>               die_error("400 Bad Request", "Object is not a blob");
>       }
> -     open ($fd, "-|", git_cmd(), "blame", '-l', $file_name, $hash_base)
> +     open ($fd, "-|", git_cmd(), "blame", '-l', '--', $file_name, $hash_base)
>               or die_error(undef, "Open git-blame failed");
>       git_header_html();
>       my $formats_nav =

Slightly unrelated change. Shouldn't it be

        open $fd, "-|", git_cmd(), "blame", '-l', $hash_base, "--", $file_name

by the way?

> @@ -3135,7 +3125,7 @@ sub git_blobdiff {
>                       -type => 'text/plain',
>                       -charset => 'utf-8',
>                       -expires => $expires,
> -                     -content_disposition => qq(inline; filename="${file_name}.patch"));
> +                     -content_disposition => qq(inline; filename=") . quotemeta($file_name) . qq(.patch"));
>  
>               print "X-Git-Url: " . $cgi->self_url() . "\n\n";
>  

I'd check other places where we output Content-Disposition: header.
At least one place needs similar quotemeta somewhere.

> @@ -3585,7 +3575,7 @@ XML
>                       if (!($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/)) {
>                               next;
>                       }
> -                     my $file = validate_input(unquote($7));
> +                     my $file = esc_html(unquote($7));
>                       $file = decode("utf8", $file, Encode::FB_DEFAULT);
>                       print "$file<br/>\n";
>               }

I'd say perhaps

        my $file = unquote($7);
        $file = decode("utf8", $file, Encode::FB_DEFAULT);
        print esc_html($file) . "<br/>\n";

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

      reply	other threads:[~2006-09-24 12:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-23 22:18 [PATCH] gitweb: Consolidate escaping/validation of query string Petr Baudis
2006-09-23 22:36 ` Jakub Narebski
2006-09-23 22:41   ` Jakub Narebski
2006-09-24 11:36   ` Petr Baudis
2006-09-24 12:21     ` Jakub Narebski
2006-09-24 11:39   ` Petr Baudis
2006-09-24 12:31     ` Jakub Narebski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='ef5tqa$bjd$1@sea.gmane.org' \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).