All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jakub Narębski" <jnareb@gmail.com>
To: Michael Wagner <mail@mwagner.org>
Cc: Git Mailing List <git@vger.kernel.org>,
	Peter Krefting <peter@softwolves.pp.se>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] gitweb: Harden UTF-8 handling in generated links
Date: Wed, 04 Jun 2014 20:47:54 +0200	[thread overview]
Message-ID: <538F69DA.9010201@gmail.com> (raw)
In-Reply-To: <20140604154128.GA28549@localhost.localdomain>

Michael Wagner wrote:
> On Tue, May 27, 2014 at 04:22:42PM +0200, Jakub Narębski wrote:

>> Subject: [PATCH] gitweb: Harden UTF-8 handling in generated links
>>
>> esc_html() ensures that its input is properly UTF-8 encoded and marked
>> as UTF-8 with to_utf8().  Make esc_param() (used for query parameters
>> in generated URLs), esc_path_info() (for escaping path_info
>> components) and esc_url() use it too.
>>
>> This hardens gitweb against errors in UTF-8 handling; because
>> to_utf8() is idempotent it won't change correct output.
[...]
>>   sub esc_param {
>>   	my $str = shift;
>>   	return undef unless defined $str;
>> +
>> +	$str = to_utf8($str);
>>   	$str =~ s/([^A-Za-z0-9\-_.~()\/:@ ]+)/CGI::escape($1)/eg;
>>   	$str =~ s/ /\+/g;
>> +
>>   	return $str;
>>   }   
 
> While trying to view a "blob_plain" of "Gütekritierien.txt", a 404 error
> occured. "git_get_hash_by_path" tries to resolve the hash with the wrong
> filename (git ls-tree -z HEAD -- Gütekriterien.txt) and fails.
> 
> The filename needs the correct encoding. Something like this is probably
> needed for all filenames and should be done at a prior stage:

True.

First, I wonder why the tests I did for this situation didn't
show any errors even before the "harden href()" patch. What
is different in your config that you see those errors?

> ---
>   gitweb/gitweb.perl |    2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 77e1312..e4a50e7 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -4725,7 +4725,7 @@ sub git_print_tree_entry {
>                  }
>                  print " | " .
>                          $cgi->a({-href => href(action=>"blob_plain", hash_base=>$hash_base,
> -                                              file_name=>"$basedir$t->{'name'}")},
> +                                              file_name=>"$basedir" . to_utf8($t->{'name'}))},

Second, my "harder href()" patch does not work for this because
concatenation of non-UFT8 with UTF8 string screws up Perl
knowledge what is and isn't UTF8.  So to_utf8() after concat
doesn't help.


>                                  "raw");
>                  print "</td>\n";
> 

  reply	other threads:[~2014-06-04 18:48 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-14 18:41 [PATCH/RFC] Gitweb: Convert UTF-8 encoded file names Michael Wagner
2014-05-14 21:57 ` Junio C Hamano
2014-05-14 22:25   ` Jakub Narębski
2014-05-15  5:08     ` Michael Wagner
2014-05-15  9:04       ` Peter Krefting
2014-05-15 17:24         ` Junio C Hamano
2014-05-15 18:48         ` Michael Wagner
2014-05-15 19:28           ` Jakub Narębski
2014-05-15 19:37             ` Jakub Narębski
2014-05-15 19:38             ` Junio C Hamano
2014-05-15 20:45               ` Jakub Narębski
2014-05-16  1:26                 ` Junio C Hamano
2014-05-16  7:54                   ` Jakub Narębski
2014-05-16 17:05                     ` Junio C Hamano
2014-05-27 14:18                       ` Jakub Narębski
2014-05-16 18:17                     ` Junio C Hamano
2014-05-27 14:22             ` [PATCH] gitweb: Harden UTF-8 handling in generated links Jakub Narębski
2014-06-04 15:41               ` Michael Wagner
2014-06-04 18:47                 ` Jakub Narębski [this message]
2014-06-04 20:47                   ` Michael Wagner
2015-03-23 21:35                   ` What's cooking in git.git (Mar 2015, #08; Mon, 23) Junio C Hamano
2014-12-17 14:18                     ` [PATCH v4] remote: add --fetch and --both options to set-url Peter Wu
2014-12-17 14:32                       ` Jeff King
2014-12-17 14:42                         ` Peter Wu
2014-12-17 22:31                       ` Junio C Hamano
2015-03-24 22:21                       ` What's cooking in git.git (Mar 2015, #08; Mon, 23) Junio C Hamano
2015-03-26 16:18                         ` Jeff King
2015-03-24 20:02                     ` Junio C Hamano
2015-03-24 20:04                       ` Jeff King
2015-03-24 20:08                     ` Junio C Hamano
2015-03-24 23:37                     ` Junio C Hamano
2015-03-24 22:26                   ` Junio C Hamano
2015-03-25  0:37                     ` Jakub Narębski
2015-03-25  1:05                       ` Junio C Hamano
2014-05-15 12:32       ` [PATCH/RFC] Gitweb: Convert UTF-8 encoded file names Jakub Narębski

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=538F69DA.9010201@gmail.com \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=mail@mwagner.org \
    --cc=peter@softwolves.pp.se \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.