[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] CVS: koha/misc/translator TmplTokenizer.pm,1.24,1.25
From: |
Ambrose C. LI |
Subject: |
[Koha-cvs] CVS: koha/misc/translator TmplTokenizer.pm,1.24,1.25 |
Date: |
Mon, 23 Feb 2004 10:49:58 -0800 |
Update of /cvsroot/koha/koha/misc/translator
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19729
Modified Files:
TmplTokenizer.pm
Log Message:
Fixed a bug which caused </script> to be not recognized as a tag
Index: TmplTokenizer.pm
===================================================================
RCS file: /cvsroot/koha/koha/misc/translator/TmplTokenizer.pm,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -r1.24 -r1.25
*** TmplTokenizer.pm 23 Feb 2004 04:36:56 -0000 1.24
--- TmplTokenizer.pm 23 Feb 2004 18:49:56 -0000 1.25
***************
*** 324,332 ****
if ($this->cdata_mode_p) {
my $next = $this->_pop_readahead;
! if ($next =~ /^$cdata_close/) {
($kind, $it) = (TmplTokenType::TAG, $&);
$this->_push_readahead( $' );
$ok_p = 1;
! } elsif ($next =~ /^((?:(?!$cdata_close).)+)($cdata_close)/) {
($kind, $it) = (TmplTokenType::TEXT, $1);
$this->_push_readahead( "$2$'" );
--- 324,332 ----
if ($this->cdata_mode_p) {
my $next = $this->_pop_readahead;
! if ($next =~ /^$cdata_close/is) {
($kind, $it) = (TmplTokenType::TAG, $&);
$this->_push_readahead( $' );
$ok_p = 1;
! } elsif ($next =~ /^((?:(?!$cdata_close).)+)($cdata_close)/is) {
($kind, $it) = (TmplTokenType::TEXT, $1);
$this->_push_readahead( "$2$'" );
***************
*** 398,402 ****
$it = $this->_next_token_internal($h);
if (defined $it && $it->type == TmplTokenType::TAG) {
! if ($it->string =~ /^<(script|style|textarea)\b/i) {
$this->_set_cdata_mode( 1 );
$this->_set_cdata_close( "</$1\\s*>" );
--- 398,402 ----
$it = $this->_next_token_internal($h);
if (defined $it && $it->type == TmplTokenType::TAG) {
! if ($it->string =~ /^<(script|style|textarea)\b/is) {
$this->_set_cdata_mode( 1 );
$this->_set_cdata_close( "</$1\\s*>" );
***************
*** 408,412 ****
my $next = $this->_next_token_internal($h);
last if !defined $next;
! if (defined $next && $next->string =~ /$cdata_close/i) {
$this->_push_readahead( $next ); # push entire TmplToken object
$this->_set_cdata_mode( 0 );
--- 408,412 ----
my $next = $this->_next_token_internal($h);
last if !defined $next;
! if (defined $next && $next->string =~ /$cdata_close/is) {
$this->_push_readahead( $next ); # push entire TmplToken object
$this->_set_cdata_mode( 0 );
***************
*** 423,444 ****
sub _token_groupable1_p ($) { # as first token, groupable into
TEXT_PARAMETRIZED
my($t) = @_;
! return ($t->type == TmplTokenType::TEXT && $t->string !~ /^[,\.:\|\s]+$/s)
|| ($t->type == TmplTokenType::DIRECTIVE
&& $t->string =~ /^(?:$re_tmpl_var)$/os)
|| ($t->type == TmplTokenType::TAG
&& ($t->string =~ /^<(?:b|em|h[123456]|i|u)\b/is
! || ($t->string =~ /^<input/i
! && $t->attributes->{'type'} =~ /^(?:text)$/i)))
}
sub _token_groupable2_p ($) { # as other token, groupable into
TEXT_PARAMETRIZED
my($t) = @_;
! return ($t->type == TmplTokenType::TEXT && ($t->string =~ /^\s*$/s ||
$t->string !~ /^[\|\s]+$/s))
|| ($t->type == TmplTokenType::DIRECTIVE
&& $t->string =~ /^(?:$re_tmpl_var)$/os)
|| ($t->type == TmplTokenType::TAG
&& ($t->string =~ /^<\/?(?:a|b|em|h[123456]|i|u)\b/is
! || ($t->string =~ /^<input/i
! && $t->attributes->{'type'} =~ /^(?:text)$/i)))
}
--- 423,445 ----
sub _token_groupable1_p ($) { # as first token, groupable into
TEXT_PARAMETRIZED
my($t) = @_;
! return ($t->type == TmplTokenType::TEXT && $t->string !~
/^[,\.:\|\s]+$/is)
|| ($t->type == TmplTokenType::DIRECTIVE
&& $t->string =~ /^(?:$re_tmpl_var)$/os)
|| ($t->type == TmplTokenType::TAG
&& ($t->string =~ /^<(?:b|em|h[123456]|i|u)\b/is
! # || ($t->string =~ /^<input\b/is
! # && $t->attributes->{'type'}->[1] =~ /^(?:radio|text)$/is)
! ))
}
sub _token_groupable2_p ($) { # as other token, groupable into
TEXT_PARAMETRIZED
my($t) = @_;
! return ($t->type == TmplTokenType::TEXT && ($t->string =~ /^\s*$/s ||
$t->string !~ /^[\|\s]+$/is))
|| ($t->type == TmplTokenType::DIRECTIVE
&& $t->string =~ /^(?:$re_tmpl_var)$/os)
|| ($t->type == TmplTokenType::TAG
&& ($t->string =~ /^<\/?(?:a|b|em|h[123456]|i|u)\b/is
! || ($t->string =~ /^<input\b/is
! && $t->attributes->{'type'} =~ /^(?:radio|text)$/is)))
}
***************
*** 469,473 ****
_formalize_string_cformat($t->string):
$t->type == TmplTokenType::TAG?
! ($t->string =~ /^<a\b/is? '<a>': _quote_cformat($t->string)):
_quote_cformat($t->string);
}
--- 470,476 ----
_formalize_string_cformat($t->string):
$t->type == TmplTokenType::TAG?
! ($t->string =~ /^<a\b/is? '<a>':
! $t->string =~ /^<input\b/is? '<input>':
! _quote_cformat($t->string)):
_quote_cformat($t->string);
}
***************
*** 515,521 ****
for (my $i = 0; $i <= $#structure; $i += 1) {
if ($structure[$i]->type == TmplTokenType::TAG) {
! if ($structure[$i]->string =~ /^<([A-Z0-9]+)/i) {
! push @tags, lc($1);
! } elsif ($structure[$i]->string =~ /^<\/([A-Z0-9]+)/i) {
if (@tags && lc($1) eq $tags[$#tags]) {
pop @tags;
--- 518,526 ----
for (my $i = 0; $i <= $#structure; $i += 1) {
if ($structure[$i]->type == TmplTokenType::TAG) {
! if ($structure[$i]->string =~ /^<([A-Z0-9]+)/is) {
! my $tag = lc($1);
! push @tags, $tag unless $tag =~ /^<(?:input)/is
! || $tag =~ /\/>$/is;
! } elsif ($structure[$i]->string =~ /^<\/([A-Z0-9]+)/is) {
if (@tags && lc($1) eq $tags[$#tags]) {
pop @tags;
***************
*** 550,554 ****
my @tags = ();
my $next = undef;
! my($nonblank_text_p, $parametrized_p, $with_anchor_p) = (0, 0, 0);
if ($it->type == TmplTokenType::TEXT) {
$nonblank_text_p = 1 if !blank_p( $it->string );
--- 555,559 ----
my @tags = ();
my $next = undef;
! my($nonblank_text_p, $parametrized_p, $with_anchor_p,
$with_input_p) = (0, 0, 0, 0);
if ($it->type == TmplTokenType::TEXT) {
$nonblank_text_p = 1 if !blank_p( $it->string );
***************
*** 558,561 ****
--- 563,567 ----
push @tags, lc($1);
$with_anchor_p = 1 if lc($1) eq 'a';
+ $with_input_p = 1 if lc($1) eq 'input';
}
# We hate | and || in msgid strings, so we try to avoid them
***************
*** 574,577 ****
--- 580,584 ----
push @tags, lc($1);
$with_anchor_p = 1 if lc($1) eq 'a';
+ $with_input_p = 1 if lc($1) eq 'input';
} elsif ($next->string =~ /^<\/([A-Z0-9]+)/is) {
my $close = lc($1);
***************
*** 590,608 ****
# Nothing to do
;
! } elsif ($nonblank_text_p && ($parametrized_p || $with_anchor_p)) {
# Create the corresponding c-format string
my $string = join('', map { $_->string } @structure);
my $form = join('', map { _formalize $_ } @structure);
! my $a_counter = 0;
$form =~ s/<a>/ $a_counter += 1, "<a$a_counter>" /egs;
! $it = TmplToken->new($string, TmplTokenType::TEXT_PARAMETRIZED,
$it->line_number, $it->pathname);
$it->set_form( $form );
$it->set_children( @structure );
} elsif ($nonblank_text_p
! && looks_plausibly_like_groupable_text_p( @structure )
! && $structure[$#structure]->type == TmplTokenType::TEXT) {
# Combine the strings
my $string = join('', map { $_->string } @structure);
! $it = TmplToken->new($string, TmplTokenType::TEXT,
$it->line_number, $it->pathname);;
} else {
# Requeue the tokens thus seen for re-emitting
--- 597,618 ----
# Nothing to do
;
! } elsif ($nonblank_text_p && ($parametrized_p || $with_anchor_p ||
$with_input_p)) {
# Create the corresponding c-format string
my $string = join('', map { $_->string } @structure);
my $form = join('', map { _formalize $_ } @structure);
! my($a_counter, $input_counter) = (0, 0);
$form =~ s/<a>/ $a_counter += 1, "<a$a_counter>" /egs;
! $form =~ s/<input>/ $input_counter += 1,
"<input$input_counter>" /egs;
! $it = TmplToken->new($string, TmplTokenType::TEXT_PARAMETRIZED,
! $it->line_number, $it->pathname);
$it->set_form( $form );
$it->set_children( @structure );
} elsif ($nonblank_text_p
! && looks_plausibly_like_groupable_text_p( @structure )
! && $structure[$#structure]->type == TmplTokenType::TEXT) {
# Combine the strings
my $string = join('', map { $_->string } @structure);
! $it = TmplToken->new($string, TmplTokenType::TEXT,
! $it->line_number, $it->pathname);;
} else {
# Requeue the tokens thus seen for re-emitting
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] CVS: koha/misc/translator TmplTokenizer.pm,1.24,1.25,
Ambrose C. LI <=