From: Michael Wagner <accounts@mwagner.org>
To: Peter Krefting <peter@softwolves.pp.se>
Cc: "Jakub Narębski" <jnareb@gmail.com>,
"Junio C Hamano" <gitster@pobox.com>, git <git@vger.kernel.org>
Subject: Re: [PATCH/RFC] Gitweb: Convert UTF-8 encoded file names
Date: Thu, 15 May 2014 20:48:09 +0200 [thread overview]
Message-ID: <20140515184808.GA7964@localhost.localdomain> (raw)
In-Reply-To: <alpine.DEB.2.00.1405150957520.10221@ds9.cixit.se>
On Thu, May 15, 2014 at 10:04:24AM +0100, Peter Krefting wrote:
> Michael Wagner:
>
> >Decoding the UTF-8 encoded file name (again with an additional print
> >statement):
> >
> >$ REQUEST_METHOD=GET QUERY_STRING='p=notes.git;a=blob_plain;f=work/G%C3%83%C2%BCtekriterien.txt;hb=HEAD' ./gitweb.cgi
> >
> >work/Gütekriterien.txt
> >Content-disposition: inline; filename="work/Gütekriterien.txt"
>
> You should fix the code path that created that URI, though, as it is not
> what you expected.
>
> %C3%83 decodes to U+00C3 Latin Capital Letter A With Tilde
> %C2%BC decodes to U+00BC Vulgar Graction One Quarter
>
> The proper UTF-8 encoding for ü (U+00FC) is, as you can probably guess from
> looking at which two characters the sequence above yielded, C3 BC, which in
> a URI is represented as %C3%BC.
>
> Your QUERY_STRING should thus be
>
> p=notes.git;a=blob_plain;f=work/G%C3%BCtekriterien.txt;hb=HEAD
>
> which probably works as expected.
Obviously, you are right, thanks.
>
> What is happening is that whatever is generating the URI us UTF-8-encoding
> the string twice (i.e., it generates a string with the proper C3 BC in it,
> and then interprets it as iso-8859-1 data and runs that through a UTF-8
> encoder again, yielding the C3 83 C2 BC sequence you see above).
>
The subroutine "git tree" generates the tree view. It stores the output
of "git ls-tree -z ..." in an array named "@entries". Printing the content
of this array yields the following result:
00644 blob 6419cd06a9461c38d4f94d9705d97eaaa887156a 520 Gütekriterien.txt
This leads to the "doubled" encoding. Declaring the encoding in the call
to open yields the following result:
100644 blob 6419cd06a9461c38d4f94d9705d97eaaa887156a 520 Gütekriterien.txt
---
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index a9f57d6..f1414e1 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -7138,7 +7138,7 @@ sub git_tree {
my @entries = ();
{
local $/ = "\0";
- open my $fd, "-|", git_cmd(), "ls-tree", '-z',
+ open my $fd, "-|encoding(UTF-8)", git_cmd(), "ls-tree", '-z',
($show_sizes ? '-l' : ()), @extra_options, $hash
or die_error(500, "Open git-ls-tree failed");
@entries = map { chomp; $_ } <$fd>;
> --
> \\// Peter - http://www.softwolves.pp.se/
next prev parent reply other threads:[~2014-05-15 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 [this message]
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
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=20140515184808.GA7964@localhost.localdomain \
--to=accounts@mwagner.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jnareb@gmail.com \
--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 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).