git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] gitweb: fix UTF-8 encoding when using CGI::Fast

From
JMJulien Moutinho <julm+git@sourcephile.fr>
Date
Mar 29, 2020, 19:14 UTC
Message-ID
<20200329191400.eh377knm4fxm66pd@sourcephile.fr>
In-Reply-To
<xmqqr1xbb0xr.fsf@gitster.c.googlers.com>
Le dim. 29 mars 2020 09h06 -0700, Junio C Hamano a écrit :
Show 11 quoted lines
> Julien Moutinho <julm+git@sourcephile.fr> writes:
> >  	require CGI::Fast;
> >  	our $CGI = 'CGI::Fast';
> > +	# FCGI is not Unicode aware hence the UTF-8 encoding must be done manually.
> > +	# However no encoding must be done within git_blob_plain() and git_snapshot()
> > +	# which must still output in raw binary mode.
> 
> I guess this comment would be sufficient to help future developers
> when they find that newer version of CGI::Fast has become Unicode
> aware later can make this part conditional to the version of the
> module, perhaps?

Sure, though as long as CGI::Fast will be relying on FCGI, I would not bet on any improvement on this bug which has been waiting to be fixed on FCGI's bugtracker since 2013: https://rt.cpan.org/Public/Bug/Display.html?id=89383

> Would "use CGI::Fast (-utf8)" instead of the whole thing help, by
> the way?
Unfortunately not, the -utf8 option (aka. $CGI::$PARAM_UTF8)
controls the decoding of the input parameters,
not the encoding of the output.
- https://metacpan.org/pod/CGI#-utf8
- https://stackoverflow.com/questions/5005104/how-to-force-fastcgi-to-encode-form-data-as-utf-8-as-cgi-pm-has-option/7097698#7097698
> > our $FCGI_Stream_PRINT_raw = \&FCGI::Stream::PRINT;
> [...]
> > +	local *FCGI::Stream::PRINT = $FCGI_Stream_PRINT_raw;

I had forgotten to test the patch without FastCGI, but AFAICS it is innocuous in non-FastCGI mode: Perl does not chokes on \&FCGI::Stream::PRINT despite it being not reachable, and the local binding emits no redefine warning since it's not a redefine in this case, but a define.

Regards,
Previous: Junio C Hamano
Message 3 of 3 in “gitweb: fix UTF-8 encoding when using CGI::Fast”
  1. gitweb: fix UTF-8 encoding when using CGI::FastJulien Moutinho, Mar 29, 2020
  2. Junio C HamanoMar 29, 2020
  3. Julien MoutinhoMar 29, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.