[Swfdec] 5 commits - libswfdec/swfdec_html_parser.c libswfdec/swfdec_text_field.c libswfdec/swfdec_text_field_movie_as.c libswfdec/swfdec_text_field_movie.c libswfdec/swfdec_xml.c test/trace

Pekka Lampila medar at kemper.freedesktop.org
Sat Oct 13 05:20:26 PDT 2007


 libswfdec/swfdec_html_parser.c         |   24 +++++++++++++++++-
 libswfdec/swfdec_text_field.c          |    2 +
 libswfdec/swfdec_text_field_movie.c    |    9 ++----
 libswfdec/swfdec_text_field_movie_as.c |    3 ++
 libswfdec/swfdec_xml.c                 |    5 +++
 test/trace/xml-escape-5.swf            |binary
 test/trace/xml-escape-6.swf            |binary
 test/trace/xml-escape-6.swf.trace      |    1 
 test/trace/xml-escape-7.swf            |binary
 test/trace/xml-escape-7.swf.trace      |    1 
 test/trace/xml-escape.as               |    4 +++
 test/trace/xml-parse-2.xml             |    8 +++---
 test/trace/xml-parse-6.swf             |binary
 test/trace/xml-parse-6.swf.trace       |   44 ++++++++++++++++-----------------
 test/trace/xml-parse-7.swf             |binary
 test/trace/xml-parse-7.swf.trace       |   44 ++++++++++++++++-----------------
 16 files changed, 90 insertions(+), 55 deletions(-)

New commits:
diff-tree c81a20e773a8322ff4d8cb3d6e4d22aacd13fe3f (from ec52d0b16b2c5001bf9e1503e49b504853cc288c)
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Sat Oct 13 14:50:19 2007 +0300

    Support parsing color from TextField's htmlText

diff --git a/libswfdec/swfdec_html_parser.c b/libswfdec/swfdec_html_parser.c
index ddd8534..3c0ca04 100644
--- a/libswfdec/swfdec_html_parser.c
+++ b/libswfdec/swfdec_html_parser.c
@@ -113,6 +113,24 @@ swfdec_text_field_movie_html_tag_set_att
     {
       swfdec_as_object_set_variable (object, SWFDEC_AS_STR_size, &val);
     }
+    else if (name_length == 5 && !g_strncasecmp (name, "color", 5))
+    {
+      SwfdecAsValue val_number;
+
+      if (value_length != 7 || *value != '#') {
+	SWFDEC_AS_VALUE_SET_NUMBER (&val_number, 0);
+      } else {
+	int number;
+	char *tail;
+
+	number = g_ascii_strtoll (value + 1, &tail, 16);
+	if (tail != value + 7)
+	  number = 0;
+	SWFDEC_AS_VALUE_SET_NUMBER (&val_number, number);
+      }
+
+      swfdec_as_object_set_variable (object, SWFDEC_AS_STR_color, &val_number);
+    }
     else if (name_length == 13 && !g_strncasecmp (name, "letterspacing", 13))
     {
       swfdec_as_object_set_variable (object, SWFDEC_AS_STR_letterSpacing,
diff-tree ec52d0b16b2c5001bf9e1503e49b504853cc288c (from 069300ee8c33a1fede5e2f07624328fbacd2f0e1)
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Sat Oct 13 14:32:12 2007 +0300

    Print FIXME about not supporting embedFonts only once when setting the property

diff --git a/libswfdec/swfdec_text_field.c b/libswfdec/swfdec_text_field.c
index 2788cfc..485d3b2 100644
--- a/libswfdec/swfdec_text_field.c
+++ b/libswfdec/swfdec_text_field.c
@@ -337,6 +337,8 @@ tag_func_define_edit_text (SwfdecSwfDeco
   reserved = swfdec_bits_getbit (b);
   text->html = swfdec_bits_getbit (b);
   text->embed_fonts = swfdec_bits_getbit (b);
+  if (text->embed_fonts)
+    SWFDEC_FIXME ("Using embed fonts in TextField is not supported");
   if (has_font) {
     SwfdecCharacter *font;
 
diff --git a/libswfdec/swfdec_text_field_movie.c b/libswfdec/swfdec_text_field_movie.c
index 2827961..21e9a79 100644
--- a/libswfdec/swfdec_text_field_movie.c
+++ b/libswfdec/swfdec_text_field_movie.c
@@ -108,7 +108,7 @@ swfdec_text_field_movie_generate_paragra
   GSList *iter;
   PangoAttribute *attr_bold, *attr_color, *attr_font, *attr_italic,
 		 *attr_letter_spacing, *attr_size, *attr_underline;
-  // TODO: kerning
+  // TODO: kerning, display
 
   g_assert (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
   g_assert (paragraph != NULL);
@@ -147,8 +147,7 @@ swfdec_text_field_movie_generate_paragra
       SWFDEC_COLOR_B (format->color) * 255);
   attr_color->start_index = 0;
 
-  if (text->text->embed_fonts)
-    SWFDEC_FIXME ("Using embed fonts in TextField not supported");
+  // FIXME: embed fonts
   attr_font = pango_attr_family_new (format->font);
   attr_font->start_index = 0;
 
@@ -213,8 +212,7 @@ swfdec_text_field_movie_generate_paragra
       attr_font->end_index = index_ - start_index;
       swfdec_text_paragraph_add_attribute (paragraph, attr_font);
 
-      if (text->text->embed_fonts)
-	SWFDEC_FIXME ("Using embed fonts in TextField not supported");
+      // FIXME: embed fonts
       attr_font = pango_attr_family_new (format->font);
       attr_font->start_index = index_ - start_index;
     }
@@ -232,7 +230,6 @@ swfdec_text_field_movie_generate_paragra
       attr_letter_spacing->end_index = index_ - start_index;
       swfdec_text_paragraph_add_attribute (paragraph, attr_letter_spacing);
 
-      // FIXME: correct scaling?
       attr_letter_spacing = pango_attr_letter_spacing_new (
 	  format->letter_spacing * 20 * PANGO_SCALE);
       attr_letter_spacing->start_index = index_ - start_index;
diff --git a/libswfdec/swfdec_text_field_movie_as.c b/libswfdec/swfdec_text_field_movie_as.c
index a4ecd5c..8d7389a 100644
--- a/libswfdec/swfdec_text_field_movie_as.c
+++ b/libswfdec/swfdec_text_field_movie_as.c
@@ -437,6 +437,9 @@ swfdec_text_field_movie_set_embedFonts (
   swfdec_as_value_to_number (cx, &argv[0]);
 
   text->text->embed_fonts = value;
+
+  if (text->text->embed_fonts)
+    SWFDEC_FIXME ("Using embed fonts in TextField not supported");
 }
 
 // does nothing but calls valueOf
diff-tree 069300ee8c33a1fede5e2f07624328fbacd2f0e1 (from 403d23918bdc4556bd3ce52819d204cd1ecfebf1)
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Sat Oct 13 14:24:48 2007 +0300

    Add tests for unescaping &nbsp;
    
    Doesn't work right in v5 currently, so no test added for that version

diff --git a/test/trace/xml-escape-5.swf b/test/trace/xml-escape-5.swf
index d558ba0..78ad1d1 100644
Binary files a/test/trace/xml-escape-5.swf and b/test/trace/xml-escape-5.swf differ
diff --git a/test/trace/xml-escape-6.swf b/test/trace/xml-escape-6.swf
index a8c7501..b6d3e36 100644
Binary files a/test/trace/xml-escape-6.swf and b/test/trace/xml-escape-6.swf differ
diff --git a/test/trace/xml-escape-6.swf.trace b/test/trace/xml-escape-6.swf.trace
index fd057c3..2a18abc 100644
--- a/test/trace/xml-escape-6.swf.trace
+++ b/test/trace/xml-escape-6.swf.trace
@@ -3,3 +3,4 @@ te&amp;lt;st
 undefined
 ma&apos;ny
 hmm&amp;amp;hrr
+non breaking space:  
diff --git a/test/trace/xml-escape-7.swf b/test/trace/xml-escape-7.swf
index c70c4a2..29d808d 100644
Binary files a/test/trace/xml-escape-7.swf and b/test/trace/xml-escape-7.swf differ
diff --git a/test/trace/xml-escape-7.swf.trace b/test/trace/xml-escape-7.swf.trace
index fd057c3..2a18abc 100644
--- a/test/trace/xml-escape-7.swf.trace
+++ b/test/trace/xml-escape-7.swf.trace
@@ -3,3 +3,4 @@ te&amp;lt;st
 undefined
 ma&apos;ny
 hmm&amp;amp;hrr
+non breaking space:  
diff --git a/test/trace/xml-escape.as b/test/trace/xml-escape.as
index 7630d2e..db89bc6 100644
--- a/test/trace/xml-escape.as
+++ b/test/trace/xml-escape.as
@@ -8,5 +8,9 @@ trace (xmlEscape ("te&lt;st"));
 trace (xmlEscape ());
 trace (xmlEscape ("ma'ny", "param&eters"));
 trace (xmlEscape ("hmm&amp;hrr"));
+// FIXME: Make it work in v5 too
+#if __SWF_VERSION__ > 5
+trace (xmlEscape ("non breaking space:  "));
+#endif
 
 loadMovie ("FSCommand:quit", "");
diff --git a/test/trace/xml-parse-2.xml b/test/trace/xml-parse-2.xml
index 70fa949..f3c2d88 100644
--- a/test/trace/xml-parse-2.xml
+++ b/test/trace/xml-parse-2.xml
@@ -13,8 +13,8 @@ cruft <?xml version="1.0" encoding="UTF-
 </normal>
 
 <!-- entities -->
-<entities entities_attribute="&lt; &gt; &quot; &apos; &amp;">
-  &lt; &gt; &quot; &apos; &amp;
+<entities entities_attribute="&lt; &gt; &quot; &apos; &amp; &nbsp;">
+  &lt; &gt; &quot; &apos; &amp; &nbsp;
 </entities>
 
 <!-- utf-8 -->
@@ -25,8 +25,8 @@ cruft <?xml version="1.0" encoding="UTF-
 <no_comment_inside_text>comment text</no_comment_inside_text>
 
 <!-- unescaped entities -->
-<unescaped entities="> ' &">
-  > " ' &
+<unescaped entities="> ' &  (nbsp)">
+  > " ' &  (nbsp)
 </unescaped>
 
 <!-- missing end element -->
diff --git a/test/trace/xml-parse-6.swf b/test/trace/xml-parse-6.swf
index f37999f..64b8174 100644
Binary files a/test/trace/xml-parse-6.swf and b/test/trace/xml-parse-6.swf differ
diff --git a/test/trace/xml-parse-6.swf.trace b/test/trace/xml-parse-6.swf.trace
index b450ce6..924e689 100644
--- a/test/trace/xml-parse-6.swf.trace
+++ b/test/trace/xml-parse-6.swf.trace
@@ -167,8 +167,8 @@ childNodes: 0: 
 Loading: xml-parse-2.xml
 Success: true
 ---
-788
-788
+820
+820
 docTypeDecl: <!DOCTYPE foo [ <!ENTITY greeting "hello"> ]>
 ignoreWhite: true
 loaded: true
@@ -301,7 +301,7 @@ nextSibling: undefined
 previousSibling: TAG(1): 'empty_element'
 childNodes: 0: 
 ---
-attributes: 1: entities%5Fattribute=%3C%20%3E%20%22%20%27%20%26
+attributes: 1: entities%5Fattribute=%3C%20%3E%20%22%20%27%20%26%20%C2%A0
 localName: entities
 namespaceURI: 
 nodeName: entities
@@ -309,18 +309,18 @@ nodeType: 1
 nodeValue: null
 prefix: 
 parentNode: TAG(1): 'null'
-firstChild: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%0A'
-lastChild: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%0A'
+firstChild: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%20%C2%A0%0A'
+lastChild: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%20%C2%A0%0A'
 nextSibling: TAG(1): '俄語'
 previousSibling: TAG(1): 'normal'
-childNodes: 1: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%0A'
+childNodes: 1: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%20%C2%A0%0A'
 ---
 attributes: 0: 
 localName: null
 namespaceURI: null
 nodeName: null
 nodeType: 3
-nodeValue: %0A%20%20%3C%20%3E%20%22%20%27%20%26%0A
+nodeValue: %0A%20%20%3C%20%3E%20%22%20%27%20%26%20%C2%A0%0A
 prefix: null
 parentNode: TAG(1): 'entities'
 firstChild: undefined
@@ -427,7 +427,7 @@ nextSibling: undefined
 previousSibling: undefined
 childNodes: 0: 
 ---
-attributes: 1: entities=%3E%20%27%20%26
+attributes: 1: entities=%3E%20%27%20%26%20%C2%A0%28nbsp%29
 localName: unescaped
 namespaceURI: 
 nodeName: unescaped
@@ -435,18 +435,18 @@ nodeType: 1
 nodeValue: null
 prefix: 
 parentNode: TAG(1): 'null'
-firstChild: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%0A'
-lastChild: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%0A'
+firstChild: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%20%C2%A0%28nbsp%29%0A'
+lastChild: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%20%C2%A0%28nbsp%29%0A'
 nextSibling: TAG(1): 'end_not_missing'
 previousSibling: TAG(1): 'no_comment_inside_text'
-childNodes: 1: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%0A'
+childNodes: 1: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%20%C2%A0%28nbsp%29%0A'
 ---
 attributes: 0: 
 localName: null
 namespaceURI: null
 nodeName: null
 nodeType: 3
-nodeValue: %0A%20%20%3E%20%22%20%27%20%26%0A
+nodeValue: %0A%20%20%3E%20%22%20%27%20%26%20%C2%A0%28nbsp%29%0A
 prefix: null
 parentNode: TAG(1): 'unescaped'
 firstChild: undefined
@@ -648,7 +648,7 @@ nextSibling: undefined
 previousSibling: TAG(1): 'empty_element'
 childNodes: 0: 
 ---
-attributes: 1: entities%5Fattribute=%3C%20%3E%20%22%20%27%20%26
+attributes: 1: entities%5Fattribute=%3C%20%3E%20%22%20%27%20%26%20%C2%A0
 localName: entities
 namespaceURI: 
 nodeName: entities
@@ -656,18 +656,18 @@ nodeType: 1
 nodeValue: null
 prefix: 
 parentNode: TAG(1): 'null'
-firstChild: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%0A'
-lastChild: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%0A'
+firstChild: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%20%C2%A0%0A'
+lastChild: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%20%C2%A0%0A'
 nextSibling: TAG(1): '俄語'
 previousSibling: TAG(1): 'normal'
-childNodes: 1: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%0A'
+childNodes: 1: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%20%C2%A0%0A'
 ---
 attributes: 0: 
 localName: null
 namespaceURI: null
 nodeName: null
 nodeType: 3
-nodeValue: %0A%20%20%3C%20%3E%20%22%20%27%20%26%0A
+nodeValue: %0A%20%20%3C%20%3E%20%22%20%27%20%26%20%C2%A0%0A
 prefix: null
 parentNode: TAG(1): 'entities'
 firstChild: undefined
@@ -774,7 +774,7 @@ nextSibling: undefined
 previousSibling: undefined
 childNodes: 0: 
 ---
-attributes: 1: entities=%3E%20%27%20%26
+attributes: 1: entities=%3E%20%27%20%26%20%C2%A0%28nbsp%29
 localName: unescaped
 namespaceURI: 
 nodeName: unescaped
@@ -782,18 +782,18 @@ nodeType: 1
 nodeValue: null
 prefix: 
 parentNode: TAG(1): 'null'
-firstChild: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%0A'
-lastChild: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%0A'
+firstChild: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%20%C2%A0%28nbsp%29%0A'
+lastChild: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%20%C2%A0%28nbsp%29%0A'
 nextSibling: TAG(1): 'end_not_missing'
 previousSibling: TAG(1): 'no_comment_inside_text'
-childNodes: 1: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%0A'
+childNodes: 1: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%20%C2%A0%28nbsp%29%0A'
 ---
 attributes: 0: 
 localName: null
 namespaceURI: null
 nodeName: null
 nodeType: 3
-nodeValue: %0A%20%20%3E%20%22%20%27%20%26%0A
+nodeValue: %0A%20%20%3E%20%22%20%27%20%26%20%C2%A0%28nbsp%29%0A
 prefix: null
 parentNode: TAG(1): 'unescaped'
 firstChild: undefined
diff --git a/test/trace/xml-parse-7.swf b/test/trace/xml-parse-7.swf
index 685c8c8..4bd5cc4 100644
Binary files a/test/trace/xml-parse-7.swf and b/test/trace/xml-parse-7.swf differ
diff --git a/test/trace/xml-parse-7.swf.trace b/test/trace/xml-parse-7.swf.trace
index b450ce6..924e689 100644
--- a/test/trace/xml-parse-7.swf.trace
+++ b/test/trace/xml-parse-7.swf.trace
@@ -167,8 +167,8 @@ childNodes: 0: 
 Loading: xml-parse-2.xml
 Success: true
 ---
-788
-788
+820
+820
 docTypeDecl: <!DOCTYPE foo [ <!ENTITY greeting "hello"> ]>
 ignoreWhite: true
 loaded: true
@@ -301,7 +301,7 @@ nextSibling: undefined
 previousSibling: TAG(1): 'empty_element'
 childNodes: 0: 
 ---
-attributes: 1: entities%5Fattribute=%3C%20%3E%20%22%20%27%20%26
+attributes: 1: entities%5Fattribute=%3C%20%3E%20%22%20%27%20%26%20%C2%A0
 localName: entities
 namespaceURI: 
 nodeName: entities
@@ -309,18 +309,18 @@ nodeType: 1
 nodeValue: null
 prefix: 
 parentNode: TAG(1): 'null'
-firstChild: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%0A'
-lastChild: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%0A'
+firstChild: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%20%C2%A0%0A'
+lastChild: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%20%C2%A0%0A'
 nextSibling: TAG(1): '俄語'
 previousSibling: TAG(1): 'normal'
-childNodes: 1: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%0A'
+childNodes: 1: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%20%C2%A0%0A'
 ---
 attributes: 0: 
 localName: null
 namespaceURI: null
 nodeName: null
 nodeType: 3
-nodeValue: %0A%20%20%3C%20%3E%20%22%20%27%20%26%0A
+nodeValue: %0A%20%20%3C%20%3E%20%22%20%27%20%26%20%C2%A0%0A
 prefix: null
 parentNode: TAG(1): 'entities'
 firstChild: undefined
@@ -427,7 +427,7 @@ nextSibling: undefined
 previousSibling: undefined
 childNodes: 0: 
 ---
-attributes: 1: entities=%3E%20%27%20%26
+attributes: 1: entities=%3E%20%27%20%26%20%C2%A0%28nbsp%29
 localName: unescaped
 namespaceURI: 
 nodeName: unescaped
@@ -435,18 +435,18 @@ nodeType: 1
 nodeValue: null
 prefix: 
 parentNode: TAG(1): 'null'
-firstChild: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%0A'
-lastChild: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%0A'
+firstChild: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%20%C2%A0%28nbsp%29%0A'
+lastChild: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%20%C2%A0%28nbsp%29%0A'
 nextSibling: TAG(1): 'end_not_missing'
 previousSibling: TAG(1): 'no_comment_inside_text'
-childNodes: 1: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%0A'
+childNodes: 1: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%20%C2%A0%28nbsp%29%0A'
 ---
 attributes: 0: 
 localName: null
 namespaceURI: null
 nodeName: null
 nodeType: 3
-nodeValue: %0A%20%20%3E%20%22%20%27%20%26%0A
+nodeValue: %0A%20%20%3E%20%22%20%27%20%26%20%C2%A0%28nbsp%29%0A
 prefix: null
 parentNode: TAG(1): 'unescaped'
 firstChild: undefined
@@ -648,7 +648,7 @@ nextSibling: undefined
 previousSibling: TAG(1): 'empty_element'
 childNodes: 0: 
 ---
-attributes: 1: entities%5Fattribute=%3C%20%3E%20%22%20%27%20%26
+attributes: 1: entities%5Fattribute=%3C%20%3E%20%22%20%27%20%26%20%C2%A0
 localName: entities
 namespaceURI: 
 nodeName: entities
@@ -656,18 +656,18 @@ nodeType: 1
 nodeValue: null
 prefix: 
 parentNode: TAG(1): 'null'
-firstChild: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%0A'
-lastChild: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%0A'
+firstChild: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%20%C2%A0%0A'
+lastChild: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%20%C2%A0%0A'
 nextSibling: TAG(1): '俄語'
 previousSibling: TAG(1): 'normal'
-childNodes: 1: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%0A'
+childNodes: 1: TEXT(3): '%0A%20%20%3C%20%3E%20%22%20%27%20%26%20%C2%A0%0A'
 ---
 attributes: 0: 
 localName: null
 namespaceURI: null
 nodeName: null
 nodeType: 3
-nodeValue: %0A%20%20%3C%20%3E%20%22%20%27%20%26%0A
+nodeValue: %0A%20%20%3C%20%3E%20%22%20%27%20%26%20%C2%A0%0A
 prefix: null
 parentNode: TAG(1): 'entities'
 firstChild: undefined
@@ -774,7 +774,7 @@ nextSibling: undefined
 previousSibling: undefined
 childNodes: 0: 
 ---
-attributes: 1: entities=%3E%20%27%20%26
+attributes: 1: entities=%3E%20%27%20%26%20%C2%A0%28nbsp%29
 localName: unescaped
 namespaceURI: 
 nodeName: unescaped
@@ -782,18 +782,18 @@ nodeType: 1
 nodeValue: null
 prefix: 
 parentNode: TAG(1): 'null'
-firstChild: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%0A'
-lastChild: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%0A'
+firstChild: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%20%C2%A0%28nbsp%29%0A'
+lastChild: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%20%C2%A0%28nbsp%29%0A'
 nextSibling: TAG(1): 'end_not_missing'
 previousSibling: TAG(1): 'no_comment_inside_text'
-childNodes: 1: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%0A'
+childNodes: 1: TEXT(3): '%0A%20%20%3E%20%22%20%27%20%26%20%C2%A0%28nbsp%29%0A'
 ---
 attributes: 0: 
 localName: null
 namespaceURI: null
 nodeName: null
 nodeType: 3
-nodeValue: %0A%20%20%3E%20%22%20%27%20%26%0A
+nodeValue: %0A%20%20%3E%20%22%20%27%20%26%20%C2%A0%28nbsp%29%0A
 prefix: null
 parentNode: TAG(1): 'unescaped'
 firstChild: undefined
diff-tree 403d23918bdc4556bd3ce52819d204cd1ecfebf1 (from 00f4fb1c5beaf4f52cc0737ff57f552690f5feb9)
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Sat Oct 13 14:23:16 2007 +0300

    Unescape &nbsp; in swfdec_xml_unescape

diff --git a/libswfdec/swfdec_xml.c b/libswfdec/swfdec_xml.c
index e932bf8..a710f15 100644
--- a/libswfdec/swfdec_xml.c
+++ b/libswfdec/swfdec_xml.c
@@ -74,6 +74,7 @@ static EntityConversion xml_entities[] =
   { '\'', "&apos;" },
   { '<', "&lt;" },
   { '>', "&gt;" },
+  { '\xa0', "&nbsp;" },
   { '\0', NULL }
 };
 
@@ -86,6 +87,7 @@ swfdec_xml_escape_len (const char *orgin
 
   string = g_string_new ("");
 
+  // Note: we don't escape non-breaking space to &nbsp;
   p = start = orginal;
   while (*(p += strcspn (p, "&<>\"'")) != '\0' && p - orginal < length) {
     string = g_string_append_len (string, start, p - start);
@@ -129,6 +131,9 @@ swfdec_xml_unescape_len (const char *org
     for (i = 0; xml_entities[i].escaped != NULL; i++) {
       if (!g_ascii_strncasecmp (p, xml_entities[i].escaped,
 	    strlen (xml_entities[i].escaped))) {
+	// FIXME: Do this cleaner
+	if (xml_entities[i].character == '\xa0')
+	  string = g_string_append_c (string, '\xc2');
 	string = g_string_append_c (string, xml_entities[i].character);
 	p += strlen (xml_entities[i].escaped);
 	break;
diff-tree 00f4fb1c5beaf4f52cc0737ff57f552690f5feb9 (from 203f8cf3a29b5fd407abf1c93ac139d38a142d1a)
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Sat Oct 13 12:37:57 2007 +0300

    Unescape text in HTML added to TextField

diff --git a/libswfdec/swfdec_html_parser.c b/libswfdec/swfdec_html_parser.c
index dcd7f1e..ddd8534 100644
--- a/libswfdec/swfdec_html_parser.c
+++ b/libswfdec/swfdec_html_parser.c
@@ -26,6 +26,7 @@
 
 #include "swfdec_text_field_movie.h"
 #include "swfdec_as_strings.h"
+#include "swfdec_xml.h"
 #include "swfdec_debug.h"
 
 typedef struct {
@@ -304,6 +305,7 @@ swfdec_text_field_movie_html_parse_text 
     gboolean condense_white)
 {
   const char *end;
+  char *unescaped;
 
   g_return_val_if_fail (data != NULL, NULL);
   g_return_val_if_fail (p != NULL, NULL);
@@ -319,7 +321,9 @@ swfdec_text_field_movie_html_parse_text 
       end = p + strcspn (p, "<\n");
     }
 
-    data->text = g_string_append_len (data->text, p, end - p);
+    unescaped = swfdec_xml_unescape_len (p, end - p);
+    data->text = g_string_append (data->text, unescaped);
+    g_free (unescaped);
 
     if (g_ascii_isspace (*end)) {
       if (condense_white) {


More information about the Swfdec mailing list