From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [RFH] t9500 failing???
Date: Wed, 12 Jun 2024 09:21:28 -0700 [thread overview]
Message-ID: <xmqqr0d2p1x3.fsf@gitster.g> (raw)
Suddenly t9500.70 has started failing for me in my local environment
(but $Corp IT folks control pretty much which version of base software
is installed and updated at what time, once I choose "I want to do CGI
in Perl" by selecting the libcgi-pm-perl module, I am not sure from
which version the thing was updated from. The Debian version claims
to be 4.62-1.
It fails with path-info test, starting at t9500.70 with extra
warning in the log. This code
if ($path_info) {
# $path_info has already been URL-decoded by the web server, but
# $my_url and $my_uri have not. URL-decode them so we can properly
# strip $path_info.
$my_url = unescape($my_url);
$my_uri = unescape($my_uri);
if ($my_url =~ s,\Q$path_info\E$,, &&
$my_uri =~ s,\Q$path_info\E$,, &&
defined $ENV{'SCRIPT_NAME'}) {
$base_url = $cgi->url(-base => 1) . $ENV{'SCRIPT_NAME'};
}
}
before it calls unescape(), I know $my_url is a
http://localhost/gitweb.cgi and after it calls unescape, it becomes
undefined. That will trigger a "Use of uninitialized value $my_url
in substitution (s///)" warning.
unescape comes from CGI::Util because we do
use CGI::Util qw(unescape);
early in the program.
As a workaround I locally have the attached patch to disable calling
CGI::Util::unescape implicitly as a sub, and instead make an
explicit call to it as a class method, and it seems to make the
tests pass. Please do not ask me why it works---the reason why I am
posting this message is to find somebody who can explain it to me ;-)
The "unescape" thing in CGI::Util.pm begins with the standard
boilerplate that lets you call it as a plain-vanilla sub as well as
a class method, like so:
# unescape URL-encoded data
sub unescape {
shift() if @_ > 0 and (ref($[0]) || (defined $[1] && $_[0] eq $CGI::DefaultClass));
but it seems that it has been that way since 2009, so it does not
explain why it started breaking for me all of sudden, even though
it _is_ curious that its counterpart in the same file, escape,
starts slightly differently to (presumably) achieve the same thing.
sub escape {
# If we being called in an OO-context, discard the first argument.
shift() if @_ > 1 and ( ref($[0]) || (defined $[1] && $_[0] eq $CGI::DefaultClass));
Notice that the former does "shift" as long as there is even a
single argument, while the latter does so only when there are at
least two arguments. Both presumably would take a single argument,
the string to either escape or unescape, and the shift is presumably
to shift away the class object if they are called as class methods,
so the guard at the beginning of unscape looks suspect, but I am not
a Perl person, and as I said, it seems that the code has been that
way since 2009, so it is very likely that I am barking up a wrong
tree.
Anyway. TIA for whoever explains the solution to this puzzle to me.
gitweb/gitweb.perl | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git c/gitweb/gitweb.perl w/gitweb/gitweb.perl
index ccd14e0e30..a0a8b79ef4 100755
--- c/gitweb/gitweb.perl
+++ w/gitweb/gitweb.perl
@@ -13,7 +13,7 @@
# handle ACL in file access tests
use filetest 'access';
use CGI qw(:standard :escapeHTML -nosticky);
-use CGI::Util qw(unescape);
+use CGI::Util qw();
use CGI::Carp qw(fatalsToBrowser set_message);
use Encode;
use Fcntl ':mode';
@@ -22,6 +22,11 @@
use Time::HiRes qw(gettimeofday tv_interval);
use Digest::MD5 qw(md5_hex);
+sub unescape {
+ my $url = shift;
+ return CGI::Util->unescape($url);
+}
+
binmode STDOUT, ':utf8';
if (!defined($CGI::VERSION) || $CGI::VERSION < 4.08) {
next reply other threads:[~2024-06-12 16:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-12 16:21 Junio C Hamano [this message]
2024-06-12 18:38 ` [RFH] t9500 failing??? Kyle Lippincott
2024-06-12 20:09 ` Junio C Hamano
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=xmqqr0d2p1x3.fsf@gitster.g \
--to=gitster@pobox.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 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.