From c11640facf0c976140547ef1b58971ec8a661dd3 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Mon, 19 Oct 2009 02:49:03 +0000 Subject: [PATCH 1/1] use EscapeHTML() from PLP v3.23 Instead of manually defining (incorrect) quote() functions to escape HTML attributes, use the new PLP feature EscapeHTML(), which was written for this purpose. --- cc.plp | 14 +++----------- charset.plp | 12 ++---------- digraphs.plp | 20 ++++++-------------- source.plp | 2 +- unicode.plp | 12 ++---------- 5 files changed, 14 insertions(+), 46 deletions(-) diff --git a/cc.plp b/cc.plp index 8473241..7138c3b 100644 --- a/cc.plp +++ b/cc.plp @@ -17,14 +17,6 @@ <: my $cc = do 'cc.inc.pl'; -sub quote { - local $_ = shift; - s/"/"/g; - s//>/g; - return $_; -} - { printf ''; print ''; @@ -62,12 +54,12 @@ sub quote { s/North(?:ern)? /N-/g; s/New /n./g; s/(\S)(\S+)-/$1-/g; # strip most chars preceding dash - s/(\S{4}[b-df-hj-np-tv-xz])(\w{2,})/$1./g; # abbreviate (at consonant) - $_ = quote($_); + s/(\S{4}[b-df-hj-np-tv-xz])((?%s', - $_ ? 'X '.$class : '', quote("$code: $name"), $_; + $_ ? 'X '.$class : '', EscapeHTML("$code: $name"), $_; } print "\n"; } diff --git a/charset.plp b/charset.plp index 29e7e23..66e0cc9 100644 --- a/charset.plp +++ b/charset.plp @@ -94,14 +94,6 @@ for my $cp437 (grep {$request[$_]->{set} eq 'cp437'} 0 .. $#request) { ); } -sub quote { - local $_ = shift; - s/"/"/g; - s//>/g; - return $_; -} - my @nibble = (0..9, 'A'..'F'); for my $row (@request) { printf '
', !$row->{cell} && ' charmap'; @@ -138,14 +130,14 @@ for my $row (@request) { } my ($codepoint, $name, $prop, $script, $string) = @$info; - $glyph = quote($string || $glyph); + $glyph = EscapeHTML($string || $glyph); my $desc = sprintf 'U+%04X%s', $codepoint, $name && " ($name)"; my @class = ('X', grep {$_} $prop, $script); $glyph = "$glyph" if $prop eq 'Zs'; printf "\n".'' for map {scalar @$_} @chars2; print "\n"; for my $section (qw{thead tfoot}) { print "<$section>'; for my $c1 (@$c1group) { - print '
%s', - join(' ', @class), quote($desc), $glyph; + join(' ', @class), EscapeHTML($desc), $glyph; } print "\n"; } diff --git a/digraphs.plp b/digraphs.plp index 5192c25..5c3bf07 100644 --- a/digraphs.plp +++ b/digraphs.plp @@ -23,14 +23,6 @@ are available as ex commands.

<: my $di = do 'digraphs.inc.pl'; -sub quote { - local $_ = shift; - s/"/"/g; - s//>/g; - return $_; -} - my @chars = ( [qw{! " % ' ( ) * + , - . /}], ['0'..'9'], [qw{: ; < = > ?}], @@ -44,13 +36,13 @@ print qq'
↳"; - print '', quote($_) for map {@$_} @chars2; + print '', EscapeHTML($_) for map {@$_} @chars2; print " \n"; } for my $c1group (@chars) { print '
', quote($c1); + print '
', EscapeHTML($c1); for my $c2 (map {@$_} @chars2) { my $mnem = $c1 . $c2; if (not defined $di->{$mnem}) { @@ -58,7 +50,7 @@ for my $c1group (@chars) { next; } if (ref $di->{$mnem} ne 'ARRAY') { - printf '', quote($mnem); + printf '', EscapeHTML($mnem); next; } my ($codepoint, $name, $prop, $script, $string) = @{ $di->{$mnem} }; @@ -68,13 +60,13 @@ for my $c1group (@chars) { my $desc = $mnem . ($name && " ($name)"); my @class = ('X', grep {$_} $prop, $script); - $glyph = quote($glyph); + $glyph = EscapeHTML($glyph); $glyph = "$glyph" if $prop eq 'Zs'; printf "\n".'%s', - join(' ', @class), quote($desc), $glyph; + join(' ', @class), EscapeHTML($desc), $glyph; } - print "\n", quote($c1), "\n"; + print "\n", EscapeHTML($c1), "\n"; } } print "
\n"; diff --git a/source.plp b/source.plp index 295f9e0..7640ae0 100644 --- a/source.plp +++ b/source.plp @@ -24,7 +24,7 @@ if (not $source) { print '\n\n"; } diff --git a/unicode.plp b/unicode.plp index ac63170..959b121 100644 --- a/unicode.plp +++ b/unicode.plp @@ -24,14 +24,6 @@ my $diinfo = do 'digraphs.inc.pl'; my %di = map { $diinfo->{$_}->[0] => $_ } grep { ref $diinfo->{$_} } sort { length $a <=> length $b } keys %$diinfo; -sub quote { - local $_ = shift; - s/"/"/g; - s//>/g; - return $_; -} - sub glyph_table { my ($digraphs) = @_; @@ -109,8 +101,8 @@ sub glyph_table { defined $name ? qq{ title="$name"} : '', @class ? sprintf(' class="%s"', join ' ', @class) : '', $colspan > 1 && qq{ colspan="$colspan"}, - $cell eq '' ? ' ' : quote($cell), - defined $code ? sprintf(' %s', quote($code)) + $cell eq '' ? ' ' : EscapeHTML($cell), + defined $code ? sprintf(' %s', EscapeHTML($code)) : length($cell) == 1 && $cell !~ /[a-z]/ ? sprintf(' %04X', 'value', ord $cell) : '', -- 2.30.0