From: Dobrica Pavlinusic Date: Sun, 22 Nov 2009 19:31:52 +0000 (+0100) Subject: correctly html escape subtitles X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=28725c23b30d0b056023a045c220601dee5974fb;p=HTML5TV.git correctly html escape subtitles --- diff --git a/bin/mplayer.pl b/bin/mplayer.pl index 9cd5b89..e5d4289 100755 --- a/bin/mplayer.pl +++ b/bin/mplayer.pl @@ -154,6 +154,15 @@ sub fmt_mmss { return sprintf('%02d:%02d', int($t/60), int($t%60)); } +my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"'); +my $escape_re = join '|' => keys %escape; +sub html_escape { + my $what = join('',@_); + $what =~ s/($escape_re)/$escape{$1}/gs; + warn "XXX html_escape $what\n"; + return $what; +} + sub html5tv { if ( ! $prop->{width} || ! $prop->{height} ) { @@ -395,7 +404,7 @@ sub html5tv { my $s = $_->{startTime}; my $e = $_->{endTime}; my $i = $_->{index}; - my $t = $_->{args}->{title}; + my $t = html_escape( $_->{args}->{title} ); my $slide = ''; $slide = $1 if $t =~ s{\s*\[(\d+)\]\s*}{};