| OLD | NEW |
| 1 #!/usr/bin/perl -wT | 1 #!/usr/bin/perl -wT |
| 2 use strict; | 2 use strict; |
| 3 use CGI; | 3 use CGI; |
| 4 use Encode; | 4 use Encode; |
| 5 | 5 |
| 6 my $cgi = new CGI; | 6 my $cgi = new CGI; |
| 7 | 7 |
| 8 use constant Unicode16BitEscapeSequenceLength => 6; # e.g. %u26C4 | 8 use constant Unicode16BitEscapeSequenceLength => 6; # e.g. %u26C4 |
| 9 my $unicode16BitEscapeSequenceRegEx = qr#%u([0-9A-Za-z]{1,4})#; | 9 my $unicode16BitEscapeSequenceRegEx = qr#%u([0-9A-Za-z]{1,4})#; |
| 10 | 10 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 } | 61 } |
| 62 $result .= substr($string, $decodedPosition, $encodedRunPosition - $deco
dedPosition); | 62 $result .= substr($string, $decodedPosition, $encodedRunPosition - $deco
dedPosition); |
| 63 $result .= decodeRunOf16BitUnicodeEscapeSequences(substr($string, $encod
edRunPosition, $encodedRunEndPosition - $encodedRunPosition)); | 63 $result .= decodeRunOf16BitUnicodeEscapeSequences(substr($string, $encod
edRunPosition, $encodedRunEndPosition - $encodedRunPosition)); |
| 64 $decodedPosition = $encodedRunEndPosition; | 64 $decodedPosition = $encodedRunEndPosition; |
| 65 } | 65 } |
| 66 $result .= substr($string, $decodedPosition); | 66 $result .= substr($string, $decodedPosition); |
| 67 return $result; | 67 return $result; |
| 68 } | 68 } |
| 69 | 69 |
| 70 my $charsetToUse = $cgi->param('charset') ? $cgi->param('charset') : "UTF-8"; | 70 my $charsetToUse = $cgi->param('charset') ? $cgi->param('charset') : "UTF-8"; |
| 71 print "X-XSS-Protection: 1\n"; |
| 71 print "Content-Type: text/html; charset=$charsetToUse\n\n"; | 72 print "Content-Type: text/html; charset=$charsetToUse\n\n"; |
| 72 | 73 |
| 73 print "<!DOCTYPE html>\n"; | 74 print "<!DOCTYPE html>\n"; |
| 74 print "<html>\n"; | 75 print "<html>\n"; |
| 75 print "<body>\n"; | 76 print "<body>\n"; |
| 76 print decode16BitUnicodeEscapeSequences($cgi->param('q')); | 77 print decode16BitUnicodeEscapeSequences($cgi->param('q')); |
| 77 print "</body>\n"; | 78 print "</body>\n"; |
| 78 print "</html>\n"; | 79 print "</html>\n"; |
| OLD | NEW |