gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog server/asobj/Global.cpp testsui...


From: Martin Guy
Subject: [Gnash-commit] gnash ChangeLog server/asobj/Global.cpp testsui...
Date: Thu, 01 Feb 2007 19:35:37 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Martin Guy <martinwguy> 07/02/01 19:35:36

Modified files:
        .              : ChangeLog 
        server/asobj   : Global.cpp 
        testsuite/actionscript.all: Global.as 

Log message:
        Implement ActionScript 5 "escape" method and testsuite clauses

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2221&r2=1.2222
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Global.cpp?cvsroot=gnash&r1=1.36&r2=1.37
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Global.as?cvsroot=gnash&r1=1.16&r2=1.17

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2221
retrieving revision 1.2222
diff -u -b -r1.2221 -r1.2222
--- ChangeLog   1 Feb 2007 18:46:57 -0000       1.2221
+++ ChangeLog   1 Feb 2007 19:35:36 -0000       1.2222
@@ -1,3 +1,8 @@
+2007-02-01 Martin Guy <address@hidden>
+
+       * server/asobj/Global.cpp: Implement ActionScript 5 "escape" method
+       * testsuite/actionscript.all/Global.as: Add test case for "escape"
+
 2007-02-01 Bernhard Rosenkraenzer <address@hidden>
 
        * Makefile.am: Add the plugin directory to our SUBDIRS when we don't

Index: server/asobj/Global.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Global.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- server/asobj/Global.cpp     1 Feb 2007 18:08:15 -0000       1.36
+++ server/asobj/Global.cpp     1 Feb 2007 19:35:36 -0000       1.37
@@ -18,7 +18,7 @@
 
 // Implementation of the Global ActionScript Object
 
-/* $Id: Global.cpp,v 1.36 2007/02/01 18:08:15 martinwguy Exp $ */
+/* $Id: Global.cpp,v 1.37 2007/02/01 19:35:36 martinwguy Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -127,6 +127,42 @@
     fn.result->set_bool(fn.arg(0).is_finite());
 }
 
+/// \brief Encode a string to URL-encoded format
+///       converting all dodgy characters to %AB hex sequences
+// "Dodgy" means
+// - ASCII control characters: 0-31 and 127
+// - Non-ASCII chars: 128-255
+// - URL syntax characters: $ & + , / : ; = ? @
+// - Unsafe characters: SPACE " < > # % { } | \ ^ ~ [ ] `
+// Encoding is a % followed by two hexadecimal characters, case insensitive.
+// See RFC1738 http://www.rfc-editor.org/rfc/rfc1738.txt,
+// Section 2.2 "URL Character Encoding Issues"
+
+static void
+as_global_escape(const fn_call& fn)
+{
+    // List of chars we must convert to escape sequences
+    // (list taken from crazy case statement in as_global_unescape)
+    const string escapees = " \"#$%&+,/:;<=>address@hidden|}~";
+    const string hexdigits = "0123456789ABCDEF";
+
+    assert(fn.nargs == 1);
+
+    string input = fn.arg(0).to_string();
+
+    for (unsigned int i=0;i<input.length(); i++)
+       {
+           unsigned c = input[i] & 0xFF;       // ensure value is 0-255 not -ve
+
+           if (c < 32 || c > 126 || escapees.find((char)c) != string::npos) {
+               input[i] = '%';
+               input.insert(++i, hexdigits.substr(c >> 4, 1));
+               input.insert(++i, hexdigits.substr(c & 0xF, 1));
+           }
+       }
+    fn.result->set_string(input.c_str());
+}
+
 /// \brief Decode a string from URL-encoded format
 //        converting all hexadecimal sequences to ASCII characters.
 static void
@@ -473,15 +509,11 @@
        number_class_init(*this); 
        string_class_init(*this); 
        array_class_init(*this);
-       // unescape
+       init_member("escape", as_global_escape);
        init_member("unescape", as_global_unescape);
-       // parseFloat
        init_member("parseFloat", as_global_parsefloat);
-       // parseInt
        init_member("parseInt", as_global_parseint);
-       // isNan
        init_member("isNaN", as_global_isnan);
-       // isFinite
        init_member("isFinite", as_global_isfinite);
 
        if ( vm.getSWFVersion() < 6 ) goto extscan;

Index: testsuite/actionscript.all/Global.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Global.as,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- testsuite/actionscript.all/Global.as        1 Feb 2007 17:47:17 -0000       
1.16
+++ testsuite/actionscript.all/Global.as        1 Feb 2007 19:35:36 -0000       
1.17
@@ -20,7 +20,7 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: Global.as,v 1.16 2007/02/01 17:47:17 martinwguy Exp $";
+rcsid="$Id: Global.as,v 1.17 2007/02/01 19:35:36 martinwguy Exp $";
 
 #include "check.as"
 
@@ -59,8 +59,12 @@
 // All %NN must become the corresponding ascii char
 check ( unescape('%3A%2F%3F%3D%26') == ':/?=&' );
 
-// All ascii char become the corresponding %NN hex
-xcheck (escape(':/?=&') == '%3A%2F%3F%3D%26');
+// All URL-special chars become the corresponding %NN hex
+check (escape(' "#$%&+,/:;<=') == '%20%22%23%24%25%26%2B%2C%2F%3A%3B%3C%3D');
+check (escape('>address@hidden|}~') == '%3E%3F%40%5B%5C%5D%5E%60%7B%7C%7D%7E');
+check (escape('!()*-._0123456789') == '!()*-._0123456789');
+check (escape('ABCDEFGHIJKLMNOPQRSTUVWXYZ') == 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
+check (escape('abcdefghijklmnopqrstuvwxyz') == 'abcdefghijklmnopqrstuvwxyz');
 
 // How to test failure of setInterval and success of clearInterval ?
 // The problem is that there is no way 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]