Subject: Re: [PATCH/RFC] Gitweb: Convert UTF-8 encoded file names

From: Junio C Hamano <[email-masked]>
Date: Wed, 14 May 2014 14:57:32 -0700

Michael Wagner <[email-masked]> writes:

> Perl has an internal encoding used to store text strings. Currently, trying to
> view files with UTF-8 encoded names results in an error (either "404 - Cannot
> find file" [blob_plain] or "XML Parsing Error" [blob]). Converting these UTF-8
> encoded file names into Perl's internal format resolves these errors.
>
> Signed-off-by: Michael Wagner <[email-masked]>
> ---

Cc'ing Jakub, who have been the area maintainer, for comments.

One thing I wonder is that, if there are some additional calls to
encode() necessary before we embed $file_name (which are now decoded
to the internal string form, not a byte-sequence that happens to be
in utf-8) in the generated pages, if we were to do this change.

>  gitweb/gitweb.perl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index a9f57d6..6046977 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -1056,7 +1056,7 @@ sub evaluate_and_validate_params {
>  		}
>  	}
>  
> -	our $file_name = $input_params{'file_name'};
> +	our $file_name = decode("utf-8", $input_params{'file_name'});
>  	if (defined $file_name) {
>  		if (!is_valid_pathname($file_name)) {
>  			die_error(400, "Invalid file parameter");