[vlc-devel] [PATCH 05/11] Fix rendering of HTML reserved characters

Devin Heitmueller dheitmueller at kernellabs.com
Thu Dec 27 07:08:17 CET 2012


If the character in the EIA-608 stream is one of the reserved characters,
escape it accordingly so that the HTML renders properly.
---
 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 06db964..d094d5a 100644
--- a/modules/codec/cc.c
+++ b/modules/codec/cc.c
@@ -1014,9 +1014,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;
-- 
1.7.9.5




More information about the vlc-devel mailing list