Skip to content

Commit

Permalink
Item13478: decode_utf8 must happen as soon as possible, and that's wh…
Browse files Browse the repository at this point in the history
…en the PATH_INFO is first analysed. Note that by the time it hits the Engine::CGI module it has already url-decoded by CGI, but only to utf8.
  • Loading branch information
Crawford Currie committed Jun 29, 2015
1 parent 82079ee commit ba0396b
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 21 deletions.
5 changes: 1 addition & 4 deletions core/lib/Foswiki.pm
Expand Up @@ -2174,7 +2174,7 @@ sub new {
# bin/script?topic=WebPreferences;defaultweb=Sandbox
my $defaultweb = $query->param('defaultweb') || $Foswiki::cfg{UsersWebName};

my $webtopic = decode_utf8( $query->path_info() || '' );
my $webtopic = $query->path_info() || '';
my $topicOverride = '';
my $topic = $query->param('topic');
if ( defined $topic ) {
Expand Down Expand Up @@ -2963,9 +2963,6 @@ sub urlEncode {
Reverses the encoding done in urlEncode.
Works on both UTF-8 encoded binary strings, and internal perl character
strings.
=cut

sub urlDecode {
Expand Down
4 changes: 2 additions & 2 deletions core/lib/Foswiki/Engine/CGI.pm
Expand Up @@ -147,7 +147,7 @@ sub preparePath {
# Clean up PATH_INFO problems, e.g. Support.CobaltRaqInstall. A valid
# PATH_INFO is '/Main/WebHome', i.e. the text after the script name;
# invalid PATH_INFO is often a full path starting with '/cgi-bin/...'.
my $pathInfo = $ENV{PATH_INFO} || '';
my $pathInfo = Foswiki::decode_utf8( $ENV{PATH_INFO} || '' );

if ( $pathInfo =~ m/['"]/g ) {
$pathInfo = substr( $pathInfo, 0, ( ( pos $pathInfo ) - 1 ) );
Expand Down Expand Up @@ -186,7 +186,7 @@ sub preparePath {
}
elsif ( length $pathInfo > 1 ) {

# This handles twiki_cgi; use the first path el after the script
# Use the first path el after the script
# name as the function
$pathInfo =~ m{^/([^/]+)(.*)};
my $first = $1; # implicit untaint OK; checked below
Expand Down
14 changes: 0 additions & 14 deletions core/lib/Foswiki/Request.pm
Expand Up @@ -478,20 +478,6 @@ sub param {

=begin TML
---++ ObjectMethod unicode_param( $name ) -> $firstValue
Special case of param() which takes care of decoding the parameter with
name $name from utf8 to unicode.
=cut

sub unicode_param {
my ( $this, $key ) = @_;
return Foswiki::decode_utf8( $this->param($key) );
}

=begin TML
---++ ObjectMethod cookie($name [, $value, $path, $secure, $expires]) -> $value
* If called without parameters returns a list of cookie names.
Expand Down
1 change: 0 additions & 1 deletion core/lib/Foswiki/UI/Viewfile.pm
Expand Up @@ -81,7 +81,6 @@ sub viewfile {

# If we have path_info but no ?filename=
if ($pathInfo) {
$pathInfo = Foswiki::decode_utf8($pathInfo);
my @path = split( /\/+/, $pathInfo );
shift(@path) unless ( $path[0] ); # remove leading empty string

Expand Down

0 comments on commit ba0396b

Please sign in to comment.