Index: TWiki.pm =================================================================== RCS file: /cvsroot/twiki/twiki/lib/TWiki.pm,v retrieving revision 1.234 retrieving revision 1.235 diff -U3 -r1.234 -r1.235 --- TWiki.pm 5 Sep 2003 06:22:43 -0000 1.234 +++ TWiki.pm 10 Sep 2003 16:55:45 -0000 1.235 @@ -776,7 +776,7 @@ # ========================= # Build hashes to translate in both directions between username (e.g. jsmith) -# WikiName (e.g. JaneSmith) +# and WikiName (e.g. JaneSmith) sub userToWikiListInit { my $text = &TWiki::Store::readFile( $userListFilename ); @@ -1816,8 +1816,7 @@ } # ========================= -# Encode 8-bit-set characters for use in URLs (not using UTF8 URL -# encoding by browser) +# Encode URLs sub handleUrlEncode { my( $theStr, $doExtract ) = @_; @@ -1828,12 +1827,33 @@ $theStr =~ s/\&/\%26/g; $theStr =~ s/\/\%3E/g; + # Encode characters with 8th bit set (ASCII-derived charsets only) $theStr =~ s/([\x7f-\xff])/'%' . unpack( "H*", $1 ) /ge; return $theStr; } # ========================= +# Encode characters with 8th bit set for use in URLs (not using UTF8 URL +# encoding by browser) - mainly for Mozilla +sub handleIntUrlEncode +{ + my( $theStr, $doExtract ) = @_; + + # Detect EBCDIC platform + my $isEbcdic = ( 'A' eq chr(193) ); + if( $isEbcdic ) { + # URL encoding breaks EBCDIC, so just strip double quotes + $theStr =~ s/^"(.*)"$/$1/; + return $theStr; + } else { + # Normal case + return handleUrlEncode( $theStr, $doExtract ); + } + +} + +# ========================= sub handleEnvVariable { my( $theVar ) = @_; @@ -1919,7 +1939,7 @@ $_[0] =~ s/%ICON{(.*?)}%/&handleIcon($1)/geo; $_[0] =~ s/%URLPARAM{(.*?)}%/&handleUrlParam($1)/ge; $_[0] =~ s/%URLENCODE{(.*?)}%/&handleUrlEncode($1,1)/ge; - $_[0] =~ s/%INTURLENCODE{(.*?)}%/&handleUrlEncode($1,1)/ge; + $_[0] =~ s/%INTURLENCODE{(.*?)}%/&handleIntUrlEncode($1,1)/ge; $_[0] =~ s/%DATE%/&getGmDate()/ge; # deprecated, but used in signatures $_[0] =~ s/%GMTIME%/&handleTime("","gmtime")/ge; $_[0] =~ s/%GMTIME{(.*?)}%/&handleTime($1,"gmtime")/ge; @@ -2716,8 +2736,9 @@ # Initial cleanup $text =~ s/\r//g; $text =~ s/(\n?)$/\n\n/s; # clutch to enforce correct rendering at end of doc - $text =~ s/$TranslationToken/!/go; # Convert any occurrences of token - # (very unlikely) + # Convert any occurrences of token (very unlikely - details in + # Codev.NationalCharTokenClash) + $text =~ s/$TranslationToken/!/go; my @verbatim = (); $text = takeOutVerbatim( $text, \@verbatim );