[vlc-commits] Fix rendering of HTML reserved characters

Devin Heitmueller git at videolan.org
Mon Dec 31 14:00:04 CET 2012


vlc | branch: master | Devin Heitmueller <dheitmueller at kernellabs.com> | Thu Dec 27 01:08:17 2012 -0500| [4536d80970edb271210eace32112e2a465029747] | committer: Rafaël Carré

Fix rendering of HTML reserved characters

If the character in the EIA-608 stream is one of the reserved characters,
escape it accordingly so that the HTML renders properly.

Signed-off-by: Rafaël Carré <funman at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4536d80970edb271210eace32112e2a465029747
---

 modules/codec/cc.c |   31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/modules/codec/cc.c b/modules/codec/cc.c
index eeb8793..f20ae20 100644
--- a/modules/codec/cc.c
+++ b/modules/codec/cc.c
@@ -996,9 +996,34 @@ static void Eia608TextLine( struct eia608_screen *screen, char *psz_text, int i_
                 CAT( "<u>" );
         }
 
-        /* */ 
-        Eia608TextUtf8( utf8, p_char[x] );
-        CAT( utf8 );
+        if( b_html ) {
+            /* Escape XML reserved characters
+               http://www.w3.org/TR/xml/#syntax */
+            switch (p_char[x]) {
+            case '>':
+                CAT( ">" );
+                break;
+            case '<':
+                CAT( "<" );
+                break;
+            case '"':
+                CAT( """ );
+                break;
+            case '\'':
+                CAT( "'" );
+                break;
+            case '&':
+                CAT( "&" );
+                break;
+            default:
+                Eia608TextUtf8( utf8, p_char[x] );
+                CAT( utf8 );
+                break;
+            }
+        } else {
+            Eia608TextUtf8( utf8, p_char[x] );
+            CAT( utf8 );
+        }
 
         /* */
         b_last_underline = b_underline;



More information about the vlc-commits mailing list