From 3c20689a73473320ac05840df69860b67e1552c9 Mon Sep 17 00:00:00 2001 From: acli Date: Wed, 25 Feb 2004 06:25:29 +0000 Subject: [PATCH] After the previous change, the scanner will hang if the input is malformed in a certain way, such as having a but not matching . This should fix it. --- misc/translator/TmplTokenizer.pm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/misc/translator/TmplTokenizer.pm b/misc/translator/TmplTokenizer.pm index e31032fb2e..4b0c8a0835 100644 --- a/misc/translator/TmplTokenizer.pm +++ b/misc/translator/TmplTokenizer.pm @@ -426,9 +426,11 @@ sub _next_token_intermediate { $it->set_attributes( $this->_extract_attributes($it->string, $it->line_number) ); } } else { + my $eof_p = 0; for ($it = '', my $cdata_close = $this->cdata_close;;) { my $next = $this->_next_token_internal($h); - last if !defined $next; + $eof_p = !defined $next; + last if $eof_p; if (defined $next && $next->string =~ /$cdata_close/is) { $this->_push_readahead( $next ); # push entire TmplToken object $this->_set_cdata_mode( 0 ); @@ -436,6 +438,14 @@ sub _next_token_intermediate { last unless $this->cdata_mode_p; $it .= $next->string; } + if ($eof_p) { + $it = undef; + error_normal "Unexpected end of file while looking for " + . $this->cdata_close + . "\n", $this->line_number_start; + $this->_set_fatal( 1 ); + $this->_set_syntaxerror( 1 ); + } if ($this->pcdata_mode_p) { my $check = $it; $check =~ s/$re_directive//gos; @@ -443,9 +453,10 @@ sub _next_token_intermediate { \$pedantic_error_markup_in_pcdata_p if $check =~ /$re_tag_compat/s; } - $it = TmplToken->new( $it, TmplTokenType::CDATA, $this->line_number ); + $it = TmplToken->new( $it, TmplTokenType::CDATA, $this->line_number ) + if defined $it; $this->_set_pcdata_mode, 0; - $this->_set_cdata_close, undef; + $this->_set_cdata_close, undef unless !defined $it; } return $it; } -- 2.39.5