[Swfdec] 2 commits - libswfdec/swfdec_loadvars_as.c test/trace

Benjamin Otte company at kemper.freedesktop.org
Mon Nov 12 12:23:51 PST 2007


 libswfdec/swfdec_loadvars_as.c         |    2 -
 test/trace/Makefile.am                 |    9 ++++++
 test/trace/loadvars-decode-5.swf       |binary
 test/trace/loadvars-decode-5.swf.trace |   23 +++++++++++++++
 test/trace/loadvars-decode-6.swf       |binary
 test/trace/loadvars-decode-6.swf.trace |   23 +++++++++++++++
 test/trace/loadvars-decode-7.swf       |binary
 test/trace/loadvars-decode-7.swf.trace |   23 +++++++++++++++
 test/trace/loadvars-decode-8.swf       |binary
 test/trace/loadvars-decode-8.swf.trace |   23 +++++++++++++++
 test/trace/loadvars-decode.as          |   49 +++++++++++++++++++++++++++++++++
 11 files changed, 151 insertions(+), 1 deletion(-)

New commits:
commit 112da910c93fc66ecb0a5cd5bf8a94a8346398a9
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Nov 12 21:23:25 2007 +0100

    add test for Andreas (and variable decoding, too)

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index bbb3ac2..84fcf41 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -923,6 +923,15 @@ EXTRA_DIST = \
 	loadvars-7.swf \
 	loadvars-7.swf.trace \
 	loadvars.txt \
+	loadvars-decode.as \
+	loadvars-decode-5.swf \
+	loadvars-decode-5.swf.trace \
+	loadvars-decode-6.swf \
+	loadvars-decode-6.swf.trace \
+	loadvars-decode-7.swf \
+	loadvars-decode-7.swf.trace \
+	loadvars-decode-8.swf \
+	loadvars-decode-8.swf.trace \
 	local.swf \
 	local.swf.trace \
 	lots-of-arguments.as \
diff --git a/test/trace/loadvars-decode-5.swf b/test/trace/loadvars-decode-5.swf
new file mode 100644
index 0000000..e692d0b
Binary files /dev/null and b/test/trace/loadvars-decode-5.swf differ
diff --git a/test/trace/loadvars-decode-5.swf.trace b/test/trace/loadvars-decode-5.swf.trace
new file mode 100644
index 0000000..5ee0305
--- /dev/null
+++ b/test/trace/loadvars-decode-5.swf.trace
@@ -0,0 +1,23 @@
+>>> a=b&c=d
+a = b
+c = d
+decode = 
+>>> %26=%3d&%3D=%26
+& = =
+= = &
+decode = 
+>>> 
+decode = 
+>>> ???=???
+??? = ???
+decode = 
+>>> a=
+a = 
+decode = 
+>>> =b
+decode = 
+>>> a=&=b&c&d=e
+a = 
+c = 
+d = e
+decode = 
diff --git a/test/trace/loadvars-decode-6.swf b/test/trace/loadvars-decode-6.swf
new file mode 100644
index 0000000..e79bb27
Binary files /dev/null and b/test/trace/loadvars-decode-6.swf differ
diff --git a/test/trace/loadvars-decode-6.swf.trace b/test/trace/loadvars-decode-6.swf.trace
new file mode 100644
index 0000000..e791f3e
--- /dev/null
+++ b/test/trace/loadvars-decode-6.swf.trace
@@ -0,0 +1,23 @@
+>>> a=b&c=d
+a = b
+c = d
+decode = [type Function]
+>>> %26=%3d&%3D=%26
+& = =
+= = &
+decode = [type Function]
+>>> 
+decode = [type Function]
+>>> ???=???
+??? = ???
+decode = [type Function]
+>>> a=
+a = 
+decode = [type Function]
+>>> =b
+decode = [type Function]
+>>> a=&=b&c&d=e
+a = 
+c = 
+d = e
+decode = [type Function]
diff --git a/test/trace/loadvars-decode-7.swf b/test/trace/loadvars-decode-7.swf
new file mode 100644
index 0000000..600ff61
Binary files /dev/null and b/test/trace/loadvars-decode-7.swf differ
diff --git a/test/trace/loadvars-decode-7.swf.trace b/test/trace/loadvars-decode-7.swf.trace
new file mode 100644
index 0000000..e791f3e
--- /dev/null
+++ b/test/trace/loadvars-decode-7.swf.trace
@@ -0,0 +1,23 @@
+>>> a=b&c=d
+a = b
+c = d
+decode = [type Function]
+>>> %26=%3d&%3D=%26
+& = =
+= = &
+decode = [type Function]
+>>> 
+decode = [type Function]
+>>> ???=???
+??? = ???
+decode = [type Function]
+>>> a=
+a = 
+decode = [type Function]
+>>> =b
+decode = [type Function]
+>>> a=&=b&c&d=e
+a = 
+c = 
+d = e
+decode = [type Function]
diff --git a/test/trace/loadvars-decode-8.swf b/test/trace/loadvars-decode-8.swf
new file mode 100644
index 0000000..340be84
Binary files /dev/null and b/test/trace/loadvars-decode-8.swf differ
diff --git a/test/trace/loadvars-decode-8.swf.trace b/test/trace/loadvars-decode-8.swf.trace
new file mode 100644
index 0000000..e791f3e
--- /dev/null
+++ b/test/trace/loadvars-decode-8.swf.trace
@@ -0,0 +1,23 @@
+>>> a=b&c=d
+a = b
+c = d
+decode = [type Function]
+>>> %26=%3d&%3D=%26
+& = =
+= = &
+decode = [type Function]
+>>> 
+decode = [type Function]
+>>> ???=???
+??? = ???
+decode = [type Function]
+>>> a=
+a = 
+decode = [type Function]
+>>> =b
+decode = [type Function]
+>>> a=&=b&c&d=e
+a = 
+c = 
+d = e
+decode = [type Function]
diff --git a/test/trace/loadvars-decode.as b/test/trace/loadvars-decode.as
new file mode 100644
index 0000000..ae3c64b
--- /dev/null
+++ b/test/trace/loadvars-decode.as
@@ -0,0 +1,49 @@
+// makeswf -v 7 -s 200x150 -r 1 -o loadvars-decode.swf loadvars-decode.as
+
+test = function (encoded) {
+  // print something about the test we're about to run
+  trace (">>> " + encoded);
+
+  // create a new Object.
+  o = {};
+
+  // get a special function that we know is used to decode urlencoded data.
+  // This is actually the function used as LoadVars.prototype.decode, but it
+  // works on any type of object.
+  o.decode = ASnative (301, 3);
+
+  // decode the string we got
+  o.decode (encoded);
+
+  // now print the properties that got set. Note that we can't just use a for-in
+  // loop, because they have an undefined order. Instead we collect all 
+  // variables that were set into an array, sort that array, and then print the
+  // data sorted
+  var array = [];
+  for (var i in o) {
+    array.push (i);
+  };
+  array.sort ();
+  for (var i = 0; i < array.length; i++) {
+    trace (array[i] + " = " + o[array[i]]);
+  };
+};
+
+// Let's create an array of all the strings we want to test
+tests = [
+  "a=b&c=d",
+  "%26=%3d&%3D=%26",
+  "",
+  "???=???",
+  "a=",
+  "=b",
+  "a=&=b&c&d=e"
+  //add more here :)
+];
+
+for (i = 0; i < tests.length; i++) {
+  test (tests[i]);
+};
+
+
+loadMovie ("fscommand:quit", "");
commit 3b8d2a21a43fa1cd06c28a5797dbed7dfafcbba4
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Nov 12 21:09:48 2007 +0100

    obj can be NULL

diff --git a/libswfdec/swfdec_loadvars_as.c b/libswfdec/swfdec_loadvars_as.c
index 60e8aa1..600dcb0 100644
--- a/libswfdec/swfdec_loadvars_as.c
+++ b/libswfdec/swfdec_loadvars_as.c
@@ -39,7 +39,7 @@ void
 swfdec_loadvars_decode (SwfdecAsContext *cx, SwfdecAsObject *obj,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
 {
-  if (argc < 1)
+  if (argc < 1 || obj == NULL)
     return;
 
   swfdec_as_object_decode (obj, swfdec_as_value_to_string (cx, &argv[0]));


More information about the Swfdec mailing list