Handle leading or trailing 's as leading or trailing spaces.
Make sure they are all trimmed off. $re_end_entity is now used (by the above); there are  's (no ;) in our templates.
This commit is contained in:
parent
69589b31f1
commit
a10bb7062a
|
|
@ -224,6 +224,15 @@ sub debug_dump (*) { # for testing only
|
|||
|
||||
###############################################################################
|
||||
|
||||
sub trim ($) {
|
||||
my($s) = @_;
|
||||
$s =~ s/^(?:\s|\ $re_end_entity)+//os;
|
||||
$s =~ s/(?:\s|\ $re_end_entity)+$//os;
|
||||
return $s;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
|
||||
sub text_extract (*) {
|
||||
my($h) = @_;
|
||||
my %text = ();
|
||||
|
|
@ -232,7 +241,7 @@ sub text_extract (*) {
|
|||
last unless defined $s;
|
||||
my($kind, $t, $attr) = @$s; # FIXME
|
||||
if ($kind eq KIND_TEXT) {
|
||||
$t =~ s/\s+$//s;
|
||||
$t = trim $t;
|
||||
$text{$t} = 1 if $t =~ /\S/s;
|
||||
} elsif ($kind eq KIND_TAG && %$attr) {
|
||||
# value [tag=input], meta
|
||||
|
|
@ -243,7 +252,7 @@ sub text_extract (*) {
|
|||
next if $a eq 'value' && ($tag ne 'input'
|
||||
|| (ref $attr->{'type'} && $attr->{'type'}->[1] eq 'hidden')); # FIXME
|
||||
my($key, $val, $val_orig, $order) = @{$attr->{$a}}; #FIXME
|
||||
$val =~ s/\s+$//s;
|
||||
$val = trim $val;
|
||||
$text{$val} = 1 if $val =~ /\S/s;
|
||||
}
|
||||
}
|
||||
|
|
@ -251,7 +260,8 @@ sub text_extract (*) {
|
|||
}
|
||||
# Emit all extracted strings. Don't emit pure whitespace or pure numbers.
|
||||
for my $t (keys %text) {
|
||||
printf "%s\n", $t unless $t =~ /^(?:\s|\ )*$/s || $t =~ /^\d+$/;
|
||||
printf "%s\n", $t
|
||||
unless $t =~ /^(?:\s|\ $re_end_entity)*$/os || $t =~ /^\d+$/;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue