gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r10808: Minor fix to escaping.


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10808: Minor fix to escaping.
Date: Mon, 20 Apr 2009 16:41:59 +0200
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10808
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Mon 2009-04-20 16:41:59 +0200
message:
  Minor fix to escaping.
modified:
  libcore/MovieClip.cpp
  libcore/asobj/LoadVars_as.cpp
  libcore/asobj/XMLNode_as.cpp
  libcore/namedStrings.cpp
  libcore/namedStrings.h
  testsuite/actionscript.all/LoadVars.as
    ------------------------------------------------------------
    revno: 10807.1.1
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Mon 2009-04-20 15:23:34 +0200
    message:
      Test more LoadVars properties.
    modified:
      testsuite/actionscript.all/LoadVars.as
    ------------------------------------------------------------
    revno: 10807.1.2
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Mon 2009-04-20 15:59:41 +0200
    message:
      Test more LoadVars, update totals.
      
      Add PROP_ESCAPE to namedStrings. Correct LoadVars and XML toString (should
      call _global.escape when URL escaping is required).
    modified:
      libcore/MovieClip.cpp
      libcore/asobj/LoadVars_as.cpp
      libcore/asobj/XMLNode_as.cpp
      libcore/namedStrings.cpp
      libcore/namedStrings.h
      testsuite/actionscript.all/LoadVars.as
=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp     2009-04-16 12:33:43 +0000
+++ b/libcore/MovieClip.cpp     2009-04-20 13:59:41 +0000
@@ -3543,8 +3543,7 @@
         ensureType<MovieClip>(fn.this_ptr);
 
     as_value val;
-    if (fn.nargs > 1)
-    {
+    if (fn.nargs > 1) {
         val = movieclip->callMethod(NSV::PROP_METH, fn.arg(1));
     }
     else val = movieclip->callMethod(NSV::PROP_METH);

=== modified file 'libcore/asobj/LoadVars_as.cpp'
--- a/libcore/asobj/LoadVars_as.cpp     2009-03-16 10:40:30 +0000
+++ b/libcore/asobj/LoadVars_as.cpp     2009-04-20 13:59:41 +0000
@@ -112,12 +112,19 @@
 
        enumerateProperties(vars);
 
+    as_object* global = _vm.getGlobal();
+    assert(global);
+
+    // LoadVars.toString() calls _global.escape().
        for (VarMap::const_iterator it=vars.begin(), itEnd=vars.end();
-                       it != itEnd; ++it)
-       {
+                       it != itEnd; ++it) {
+
         if (it != vars.begin()) o << "&";
-        const std::string& val = it->second;
-        o << URL::encode(it->first) << "=" << URL::encode(val);
+        const std::string& var = 
+            global->callMethod(NSV::PROP_ESCAPE, it->first).to_string();
+        const std::string& val = 
+            global->callMethod(NSV::PROP_ESCAPE, it->second).to_string();
+        o << var << "=" << val;
        }
 
 }
@@ -227,9 +234,12 @@
     return as_value(data.str()); 
 }
 
-static as_value
+as_value
 loadvars_ctor(const fn_call& fn)
 {
+
+    if (!fn.isInstantiation()) return as_value();
+
        boost::intrusive_ptr<as_object> obj = new LoadVars_as;
 
        if ( fn.nargs )

=== modified file 'libcore/asobj/XMLNode_as.cpp'
--- a/libcore/asobj/XMLNode_as.cpp      2009-03-31 09:26:54 +0000
+++ b/libcore/asobj/XMLNode_as.cpp      2009-04-20 13:59:41 +0000
@@ -377,12 +377,17 @@
     // Node as_value first, then children
     if (type == Text)
     {
+        as_object* global = xml.getVM().getGlobal();
+        assert(global);
+
         // Insert entities.
         std::string escaped(nodeValue);
         XML_as::escape(escaped);
-        if (encode) URL::encode(escaped);
+        const std::string& val = encode ? 
+            global->callMethod(NSV::PROP_ESCAPE, escaped).to_string() :
+            escaped;
 
-           xmlout << escaped;
+           xmlout << val;
     }
 
     // Childs, after node as_value.

=== modified file 'libcore/namedStrings.cpp'
--- a/libcore/namedStrings.cpp  2009-02-25 22:33:03 +0000
+++ b/libcore/namedStrings.cpp  2009-04-20 13:59:41 +0000
@@ -54,6 +54,7 @@
        string_table::svt( "data", NSV::PROP_DATA ),
        string_table::svt( "decode", NSV::PROP_DECODE ),
        string_table::svt( "e", NSV::PROP_E ),  
+       string_table::svt( "escape", NSV::PROP_ESCAPE ),        
        string_table::svt( "_droptarget", NSV::PROP_uDROPTARGET ),
        string_table::svt( "enabled", NSV::PROP_ENABLED ),
        string_table::svt( "useHandCursor", NSV::PROP_USEHANDCURSOR ),

=== modified file 'libcore/namedStrings.h'
--- a/libcore/namedStrings.h    2009-02-25 22:33:03 +0000
+++ b/libcore/namedStrings.h    2009-04-20 13:59:41 +0000
@@ -119,6 +119,7 @@
         PROP_DECODE,
                PROP_E,
                PROP_ENABLED,
+        PROP_ESCAPE,
         PROP_FOCUS_ENABLED,
         PROP_G,
                PROP_H,

=== modified file 'testsuite/actionscript.all/LoadVars.as'
--- a/testsuite/actionscript.all/LoadVars.as    2009-02-25 22:33:03 +0000
+++ b/testsuite/actionscript.all/LoadVars.as    2009-04-20 13:59:41 +0000
@@ -40,6 +40,11 @@
 
 check_equals(typeof(LoadVars), 'function');
 
+// Can only be instantiated with "new"
+lv = LoadVars();
+check_equals(lv, undefined);
+check_equals(typeof(lv), "undefined");
+
 var loadvarsObj = new LoadVars;
 
 // test the LoadVars constuctor
@@ -175,7 +180,7 @@
 // For checking that the data were loaded with XML.prototype.load.
 x.onLoad = function(success) {
     check_equals(x['var2'], 'val2');
-    check_totals(136);
+    check_totals(140);
     play();
 };
 
@@ -252,6 +257,15 @@
 check_equals(tsc, 1);
 xcheck_equals(voc, 0);
 
+// Check override of _global.escape
+
+bu = _global.escape;
+_global.escape = function(str) { return "FAKED!"; };
+lv = new LoadVars();
+lv.a = "&";
+check_equals(lv.toString(), "FAKED!=FAKED!");
+_global.escape = bu;
+check_equals(lv.toString(), "a=%26");
 
 //--------------------------------------------------------------------------
 // Test LoadVars::load()


reply via email to

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