- From: Terje Bless <link@dev.w3.org>
- Date: Sat, 05 Feb 2005 21:02:16 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/validator/httpd/cgi-bin In directory hutz:/tmp/cvs-serv18057/httpd/cgi-bin Modified Files: check Log Message: First cut at limiting recursion; cf. Bug #204. Index: check =================================================================== RCS file: /sources/public/validator/httpd/cgi-bin/check,v retrieving revision 1.391 retrieving revision 1.392 diff -u -d -r1.391 -r1.392 --- check 5 Feb 2005 04:20:57 -0000 1.391 +++ check 5 Feb 2005 21:02:14 -0000 1.392 @@ -1320,6 +1320,10 @@ return $File; } + # + # Enforce Max Recursion level. + &check_recursion($File, $res); + my($mode, $ct, $charset) = &parse_content_type( $File, @@ -1478,6 +1482,30 @@ return $mode, $ct, $charset; } +# +# Check recursion level and enforce Max Recursion limit. +sub check_recursion ($$) { + my $File = shift; + my $res = shift; + + # Not looking at our own output. + return unless defined $res->header('X-W3C-Validator-Recursion'); + + my $lvl = $res->header('X-W3C-Validator-Recursion'); + &add_warning($File, 'debug', 'Old Recursion Depth', $lvl); + return unless $lvl =~ m(^\d+$); # Non-digit, i.e. garbage, ignore. + + if ($lvl >= $CFG->{'Max Recursion'}) { + &add_warning($File, 'debug', 'Recursion Depth Limit Exceeded', + qq(Recursion depth "$lvl" exceedes limit "$CFG->{'Max Recursion'}")); + print redirect $CFG->{'Home Page'}; + } else { + $T->param(depth => $lvl++); # Increase recursion level in output. + &add_warning($File, 'debug', 'New Recursion Depth', $lvl); + } +} + + # # Normalize newline forms (CRLF/CR/LF) to native newline.
Received on Saturday, 5 February 2005 21:02:17 UTC