[Swfdec-commits] 6 commits - swfdec/swfdec_as_string.c swfdec/swfdec_file_loader.c swfdec/swfdec_text_field_movie.c swfdec/swfdec_text_field_movie.h swfdec/swfdec_url.c test/trace

Pekka Lampila medar at kemper.freedesktop.org
Fri Aug 22 07:16:15 PDT 2008


 swfdec/swfdec_as_string.c                        |    3 ++-
 swfdec/swfdec_file_loader.c                      |   15 ++++++++++++++-
 swfdec/swfdec_text_field_movie.c                 |    6 ++----
 swfdec/swfdec_text_field_movie.h                 |    2 --
 swfdec/swfdec_url.c                              |   10 ++++++----
 test/trace/Makefile.am                           |   18 ++++++++++++++++++
 test/trace/filename-with-%-character-5.swf       |binary
 test/trace/filename-with-%-character-5.swf.trace |    1 +
 test/trace/filename-with-%-character-6.swf       |binary
 test/trace/filename-with-%-character-6.swf.trace |    1 +
 test/trace/filename-with-%-character-7.swf       |binary
 test/trace/filename-with-%-character-7.swf.trace |    1 +
 test/trace/filename-with-%-character-8.swf       |binary
 test/trace/filename-with-%-character-8.swf.trace |    1 +
 test/trace/filename-with-%-character.as          |    5 +++++
 test/trace/loadobject-00-5.swf                   |binary
 test/trace/loadobject-00-5.swf.trace             |    5 +++++
 test/trace/loadobject-00-6.swf                   |binary
 test/trace/loadobject-00-6.swf.trace             |    5 +++++
 test/trace/loadobject-00-7.swf                   |binary
 test/trace/loadobject-00-7.swf.trace             |    5 +++++
 test/trace/loadobject-00-8.swf                   |binary
 test/trace/loadobject-00-8.swf.trace             |    5 +++++
 test/trace/loadobject-00.as                      |   12 ++++++++++++
 24 files changed, 83 insertions(+), 12 deletions(-)

New commits:
commit 8524f32fe2dd11eabad7cd2ad79fb82c9ceb6be9
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Fri Aug 22 17:06:36 2008 +0300

    Fix unescape function when G_STMT_START/END is expanded to do while loop
    
    We don't use break inside the macro, but skip to the end of the string instead

diff --git a/swfdec/swfdec_as_string.c b/swfdec/swfdec_as_string.c
index 8ac4f4e..2d3e8df 100644
--- a/swfdec/swfdec_as_string.c
+++ b/swfdec/swfdec_as_string.c
@@ -785,6 +785,7 @@ swfdec_as_string_unescape_6 (SwfdecAsContext *cx, const char *s)
   const guchar invalid[3] = { 0xEF, 0xBF, 0xBD };
 
 /* attention: c is a char* */
+/* can't use break inside G_STMT_START */
 #define APPEND(chr) G_STMT_START{ \
   guchar c = *chr; \
   if (utf8left) { \
@@ -807,7 +808,7 @@ swfdec_as_string_unescape_6 (SwfdecAsContext *cx, const char *s)
       g_byte_array_append (array, &__foo, 1); \
       g_byte_array_append (array, &c, 1); \
     } else if (c > 0xF7) { \
-      break; \
+      s = strchr (s, '\0'); \
     } else { \
       g_byte_array_append (array, &c, 1); \
       utf8left = (c < 0xE0) ? 1 : ((c < 0xF0) ? 2 : 3); \
commit 035fd908108066ace6dd444759b72c0cd38dd6cc
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Fri Aug 22 14:46:09 2008 +0300

    Add a test case for loading file with %00 in the name

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 9a14c81..304c863 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -1841,6 +1841,15 @@ EXTRA_DIST = \
 	loadobject-6.swf.trace \
 	loadobject-7.swf \
 	loadobject-7.swf.trace \
+	loadobject-00.as \
+	loadobject-00-5.swf \
+	loadobject-00-5.swf.trace \
+	loadobject-00-6.swf \
+	loadobject-00-6.swf.trace \
+	loadobject-00-7.swf \
+	loadobject-00-7.swf.trace \
+	loadobject-00-8.swf \
+	loadobject-00-8.swf.trace \
 	loadobject-addrequestheader.as \
 	loadobject-addrequestheader-5.swf \
 	loadobject-addrequestheader-5.swf.trace \
diff --git a/test/trace/loadobject-00-5.swf b/test/trace/loadobject-00-5.swf
new file mode 100644
index 0000000..e530f6b
Binary files /dev/null and b/test/trace/loadobject-00-5.swf differ
diff --git a/test/trace/loadobject-00-5.swf.trace b/test/trace/loadobject-00-5.swf.trace
new file mode 100644
index 0000000..78f5285
--- /dev/null
+++ b/test/trace/loadobject-00-5.swf.trace
@@ -0,0 +1,5 @@
+true
+Got: string 'test=2&hi=hello&empty_value&=empty_name&spa%20ce=spa%20ce&sp ace&spa ce=sp ace&many=equal=signs=in=row&eof=
+was there&eof
+=was there&
+'
diff --git a/test/trace/loadobject-00-6.swf b/test/trace/loadobject-00-6.swf
new file mode 100644
index 0000000..d547f11
Binary files /dev/null and b/test/trace/loadobject-00-6.swf differ
diff --git a/test/trace/loadobject-00-6.swf.trace b/test/trace/loadobject-00-6.swf.trace
new file mode 100644
index 0000000..78f5285
--- /dev/null
+++ b/test/trace/loadobject-00-6.swf.trace
@@ -0,0 +1,5 @@
+true
+Got: string 'test=2&hi=hello&empty_value&=empty_name&spa%20ce=spa%20ce&sp ace&spa ce=sp ace&many=equal=signs=in=row&eof=
+was there&eof
+=was there&
+'
diff --git a/test/trace/loadobject-00-7.swf b/test/trace/loadobject-00-7.swf
new file mode 100644
index 0000000..8a3d6e4
Binary files /dev/null and b/test/trace/loadobject-00-7.swf differ
diff --git a/test/trace/loadobject-00-7.swf.trace b/test/trace/loadobject-00-7.swf.trace
new file mode 100644
index 0000000..78f5285
--- /dev/null
+++ b/test/trace/loadobject-00-7.swf.trace
@@ -0,0 +1,5 @@
+true
+Got: string 'test=2&hi=hello&empty_value&=empty_name&spa%20ce=spa%20ce&sp ace&spa ce=sp ace&many=equal=signs=in=row&eof=
+was there&eof
+=was there&
+'
diff --git a/test/trace/loadobject-00-8.swf b/test/trace/loadobject-00-8.swf
new file mode 100644
index 0000000..83913c4
Binary files /dev/null and b/test/trace/loadobject-00-8.swf differ
diff --git a/test/trace/loadobject-00-8.swf.trace b/test/trace/loadobject-00-8.swf.trace
new file mode 100644
index 0000000..78f5285
--- /dev/null
+++ b/test/trace/loadobject-00-8.swf.trace
@@ -0,0 +1,5 @@
+true
+Got: string 'test=2&hi=hello&empty_value&=empty_name&spa%20ce=spa%20ce&sp ace&spa ce=sp ace&many=equal=signs=in=row&eof=
+was there&eof
+=was there&
+'
diff --git a/test/trace/loadobject-00.as b/test/trace/loadobject-00.as
new file mode 100644
index 0000000..683c742
--- /dev/null
+++ b/test/trace/loadobject-00.as
@@ -0,0 +1,12 @@
+// makeswf -v 7 -r 1 -o loadobject-7.swf loadobject.as
+
+var obj = new Object ();
+
+obj.load = ASnative (301, 0);
+
+obj.onData = function (str) {
+  trace ("Got: " + typeof (str) + " '" + str + "'");
+  getURL ("FSCommand:quit", "");
+};
+
+trace (obj.load ("loadvars.txt%00foobar"));
commit cf556a477f4e0be791cfde48809631f3be2b0570
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Fri Aug 22 14:44:34 2008 +0300

    Give a stream error if unescaping file path fails. Cut the path from %00

diff --git a/swfdec/swfdec_file_loader.c b/swfdec/swfdec_file_loader.c
index 2486d84..1632075 100644
--- a/swfdec/swfdec_file_loader.c
+++ b/swfdec/swfdec_file_loader.c
@@ -68,7 +68,20 @@ swfdec_file_loader_load (SwfdecLoader *loader, SwfdecPlayer *player,
     return;
   }
 
-  unescape = g_uri_unescape_string (swfdec_url_get_path (url), NULL);
+  // FIXME: Should probably use swfdec_as_string_unescape here
+  if (strstr (swfdec_url_get_path (url), "%00") != 0) {
+    char *path = g_strdup (swfdec_url_get_path (url));
+    *strstr (path, "%00") = 0;
+    unescape = g_uri_unescape_string (path, NULL);
+    g_free (path);
+  } else {
+    unescape = g_uri_unescape_string (swfdec_url_get_path (url), NULL);
+  }
+  if (unescape == NULL) {
+    swfdec_stream_error (stream, "unescaping file path failed");
+    swfdec_url_free (url);
+    return;
+  }
   /* Swfdec ignores query strings, just like Flash 9.0.124.0 and onwards.
    * Might be a useful quirk to have though */
 #ifdef QUIRKS_MODE
commit 734b442d4246c45939fd919ca4f85609389b4728
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Fri Aug 22 14:36:06 2008 +0300

    Add a test to see that a file with % in it's name gets loaded properly

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 892f155..9a14c81 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -1353,6 +1353,15 @@ EXTRA_DIST = \
 	external-interface-properties-7.swf.trace \
 	external-interface-properties-8.swf \
 	external-interface-properties-8.swf.trace \
+	filename-with-%-character.as \
+	filename-with-%-character-5.swf \
+	filename-with-%-character-5.swf.trace \
+	filename-with-%-character-6.swf \
+	filename-with-%-character-6.swf.trace \
+	filename-with-%-character-7.swf \
+	filename-with-%-character-7.swf.trace \
+	filename-with-%-character-8.swf \
+	filename-with-%-character-8.swf.trace \
 	file-reference-constructor.as \
 	file-reference-constructor-7.swf \
 	file-reference-constructor-7.swf.trace \
diff --git a/test/trace/filename-with-%-character-5.swf b/test/trace/filename-with-%-character-5.swf
new file mode 100644
index 0000000..c5b81f7
Binary files /dev/null and b/test/trace/filename-with-%-character-5.swf differ
diff --git a/test/trace/filename-with-%-character-5.swf.trace b/test/trace/filename-with-%-character-5.swf.trace
new file mode 100644
index 0000000..534df5c
--- /dev/null
+++ b/test/trace/filename-with-%-character-5.swf.trace
@@ -0,0 +1 @@
+Testing that file with % in the name will be loaded properly
diff --git a/test/trace/filename-with-%-character-6.swf b/test/trace/filename-with-%-character-6.swf
new file mode 100644
index 0000000..ea10958
Binary files /dev/null and b/test/trace/filename-with-%-character-6.swf differ
diff --git a/test/trace/filename-with-%-character-6.swf.trace b/test/trace/filename-with-%-character-6.swf.trace
new file mode 100644
index 0000000..534df5c
--- /dev/null
+++ b/test/trace/filename-with-%-character-6.swf.trace
@@ -0,0 +1 @@
+Testing that file with % in the name will be loaded properly
diff --git a/test/trace/filename-with-%-character-7.swf b/test/trace/filename-with-%-character-7.swf
new file mode 100644
index 0000000..93456d6
Binary files /dev/null and b/test/trace/filename-with-%-character-7.swf differ
diff --git a/test/trace/filename-with-%-character-7.swf.trace b/test/trace/filename-with-%-character-7.swf.trace
new file mode 100644
index 0000000..534df5c
--- /dev/null
+++ b/test/trace/filename-with-%-character-7.swf.trace
@@ -0,0 +1 @@
+Testing that file with % in the name will be loaded properly
diff --git a/test/trace/filename-with-%-character-8.swf b/test/trace/filename-with-%-character-8.swf
new file mode 100644
index 0000000..5bc5514
Binary files /dev/null and b/test/trace/filename-with-%-character-8.swf differ
diff --git a/test/trace/filename-with-%-character-8.swf.trace b/test/trace/filename-with-%-character-8.swf.trace
new file mode 100644
index 0000000..534df5c
--- /dev/null
+++ b/test/trace/filename-with-%-character-8.swf.trace
@@ -0,0 +1 @@
+Testing that file with % in the name will be loaded properly
diff --git a/test/trace/filename-with-%-character.as b/test/trace/filename-with-%-character.as
new file mode 100644
index 0000000..7429066
--- /dev/null
+++ b/test/trace/filename-with-%-character.as
@@ -0,0 +1,5 @@
+// makeswf -v 7 -r 15 -o filename-with-%-character-7.swf filename-with-%-character.as
+
+trace ("Testing that file with % in the name will be loaded properly");
+
+getURL ("FSCommand:quit", "");
commit 4f4b903cfcbb8afb63ee637ae8d1eccef2710e26
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Fri Aug 22 13:30:27 2008 +0300

    URL escape file paths in swfdec_url_new_from_input

diff --git a/swfdec/swfdec_url.c b/swfdec/swfdec_url.c
index e9fb4e1..b2b7d0a 100644
--- a/swfdec/swfdec_url.c
+++ b/swfdec/swfdec_url.c
@@ -679,16 +679,18 @@ swfdec_url_new_from_input (const char *input)
 
   /* FIXME: split at '?' for query? */
   if (g_path_is_absolute (input)) {
-    url = swfdec_url_new_components ("file", NULL, 0,
-	input[0] == '/' ? &input[1] : &input[0], NULL);
+    char *escaped =
+      g_uri_escape_string (input[0] == '/' ? &input[1] : &input[0], "/", TRUE);
+    url = swfdec_url_new_components ("file", NULL, 0, escaped, NULL);
   } else {
     char *absolute, *cur;
     cur = g_get_current_dir ();
     absolute = g_build_filename (cur, input, NULL);
     g_free (cur);
-    url = swfdec_url_new_components ("file", NULL, 0,
-	absolute, NULL);
+    cur = g_uri_escape_string (absolute, "/", TRUE);
     g_free (absolute);
+    url = swfdec_url_new_components ("file", NULL, 0, cur, NULL);
+    g_free (cur);
   }
 
   g_return_val_if_fail (url != NULL, NULL);
commit c75ebcce90267ea1822d86530c987eb767e54b6f
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Thu Aug 21 10:39:36 2008 +0300

    Use proper sandbox for TextField's asfunction links

diff --git a/swfdec/swfdec_text_field_movie.c b/swfdec/swfdec_text_field_movie.c
index 4b702b7..3140a51 100644
--- a/swfdec/swfdec_text_field_movie.c
+++ b/swfdec/swfdec_text_field_movie.c
@@ -395,8 +395,6 @@ swfdec_text_field_movie_init_movie (SwfdecMovie *movie)
 
   cx = swfdec_gc_object_get_context (movie);
 
-  text->sandbox = SWFDEC_SANDBOX (cx->global);
-
   swfdec_text_field_movie_init_properties (cx);
 
   swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_TextField, &val);
@@ -601,7 +599,7 @@ swfdec_text_field_movie_asfunction (SwfdecTextFieldMovie *text,
     return;
   }
 
-  swfdec_sandbox_use (text->sandbox);
+  swfdec_sandbox_use (SWFDEC_MOVIE (text)->resource->sandbox);
   if (parts[1] != NULL) {
     SwfdecAsValue val;
     SWFDEC_AS_VALUE_SET_STRING (&val,
@@ -610,7 +608,7 @@ swfdec_text_field_movie_asfunction (SwfdecTextFieldMovie *text,
   } else {
     swfdec_as_object_call (object, name, 0, NULL, NULL);
   }
-  swfdec_sandbox_unuse (text->sandbox);
+  swfdec_sandbox_use (SWFDEC_MOVIE (text)->resource->sandbox);
 
   g_strfreev (parts);
 }
diff --git a/swfdec/swfdec_text_field_movie.h b/swfdec/swfdec_text_field_movie.h
index 720892b..fabab63 100644
--- a/swfdec/swfdec_text_field_movie.h
+++ b/swfdec/swfdec_text_field_movie.h
@@ -43,8 +43,6 @@ typedef struct _SwfdecTextFieldMovieClass SwfdecTextFieldMovieClass;
 struct _SwfdecTextFieldMovie {
   SwfdecActor		actor;
 
-  SwfdecSandbox		*sandbox;
-
   SwfdecRect		extents;		/* original extents (copied from graphic) - queue extents update when modifying */
   /* these are updated with the movie's extents - so call swfdec_movie_update() */
   cairo_matrix_t	to_layout;		/* matrix to go from movie => layout */


More information about the Swfdec-commits mailing list