gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/asobj/LoadVars.cpp tests...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/asobj/LoadVars.cpp tests...
Date: Wed, 16 Apr 2008 23:07:15 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/04/16 23:07:15

Modified files:
        .              : ChangeLog 
        server/asobj   : LoadVars.cpp 
        testsuite/actionscript.all: LoadVars.as 
        testsuite/media: vars.txt 

Log message:
        * testsuite/actionscript.all/LoadVars.as: check that getBytesLoaded()
          is bigger then 0 when onLoad is received>
        * server/asobj/LoadVars.cpp: handle BOM mark in input file.
          Fixes bug #19915.
        * testsuite/media/vars.txt: add UTF8 BOM mark.
        
        More places will need to handle BOM, surely MovieClip.loadVariables
        and XML.load. We'll want a generic interface for dealign with it
        somewhere in the utf8 namespace. And we need to add more tests for that
        including utf16 conversion...

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6307&r2=1.6308
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/LoadVars.cpp?cvsroot=gnash&r1=1.45&r2=1.46
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/LoadVars.as?cvsroot=gnash&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/media/vars.txt?cvsroot=gnash&r1=1.2&r2=1.3

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6307
retrieving revision 1.6308
diff -u -b -r1.6307 -r1.6308
--- ChangeLog   16 Apr 2008 21:35:55 -0000      1.6307
+++ ChangeLog   16 Apr 2008 23:07:14 -0000      1.6308
@@ -1,5 +1,13 @@
 2008-04-16 Sandro Santilli <address@hidden>
 
+       * testsuite/actionscript.all/LoadVars.as: check that getBytesLoaded()
+         is bigger then 0 when onLoad is received>
+       * server/asobj/LoadVars.cpp: handle BOM mark in input file.
+         Fixes bug #19915.
+       * testsuite/media/vars.txt: add UTF8 BOM mark.
+
+2008-04-16 Sandro Santilli <address@hidden>
+
        * testsuite/actionscript.all/LoadVars.as: test that LoadVars::decode()
          would not skip BOM.
 

Index: server/asobj/LoadVars.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/LoadVars.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -b -r1.45 -r1.46
--- server/asobj/LoadVars.cpp   15 Apr 2008 11:27:20 -0000      1.45
+++ server/asobj/LoadVars.cpp   16 Apr 2008 23:07:15 -0000      1.46
@@ -245,7 +245,7 @@
 #endif
         if ( lt->completed() )
         {
-            size_t xmlsize = lt->getBytesTotal();
+            size_t xmlsize = _bytesTotal = _bytesLoaded = lt->getBytesTotal();
             boost::scoped_array<char> buf(new char[xmlsize+1]);
             size_t actuallyRead = lt->read(buf.get(), xmlsize);
             if ( actuallyRead != xmlsize )
@@ -259,7 +259,37 @@
 #endif
                        }
             buf[actuallyRead] = '\0';
-            as_value dataVal(buf.get()); // memory copy here (optimize?)
+            // Strip BOM, if any.
+            // See http://savannah.gnu.org/bugs/?19915
+            char* bufptr = buf.get();
+            log_debug("xmlsize:%d, ptr:%s", xmlsize, bufptr);
+            if ( xmlsize > 2 )
+            {
+                 // need *ptr to be unsigned or cast all 0xNN
+                 unsigned char* ptr = reinterpret_cast<unsigned char*>(bufptr);
+
+                 if ( *ptr == 0xFF && *(ptr+1) == 0xFE )
+                 {
+                     // Text is UTF-16 LE,
+                     // we should convert to UTF-8
+                     log_unimpl("Conversion from UTF-16 LE to UTF-8 
(LoadVars)");
+                     bufptr+=2;
+                 }
+                 else if ( *ptr == 0xFE && *(ptr+1) == 0xFF )
+                 {
+                     // Text is UTF-16 BE, 
+                     // we should convert to UTF-8
+                     log_unimpl("Conversion from UTF-16 BE to UTF-8 
(LoadVars)");
+                     bufptr+=2;
+                 }
+                 else if ( xmlsize > 3 && *ptr == 0xEF && *(ptr+1) == 0xBB && 
*(ptr+2) == 0xBF )
+                 {
+                     log_debug("UTF8 bom (LoadVars)");
+                     // Text is UTF-8
+                     bufptr+=3;
+                 }
+            }
+            as_value dataVal(bufptr); // memory copy here (optimize?)
 
             it = _loadThreads.erase(it);
             delete lt; // supposedly joins the thread...
@@ -273,6 +303,7 @@
         }
         else
         {
+            _bytesLoaded = lt->getBytesLoaded();
             ++it;
         }
     }

Index: testsuite/actionscript.all/LoadVars.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/LoadVars.as,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- testsuite/actionscript.all/LoadVars.as      16 Apr 2008 21:35:56 -0000      
1.28
+++ testsuite/actionscript.all/LoadVars.as      16 Apr 2008 23:07:15 -0000      
1.29
@@ -22,7 +22,7 @@
 // execute it like this gnash -1 -r 0 -v out.swf
 
 
-rcsid="$Id: LoadVars.as,v 1.28 2008/04/16 21:35:56 strk Exp $";
+rcsid="$Id: LoadVars.as,v 1.29 2008/04/16 23:07:15 strk Exp $";
 #include "check.as"
 
 #if OUTPUT_VERSION < 6
@@ -136,6 +136,8 @@
 
        //delete loadvarsObj; // this to test robustness
 
+       check_equals (loadvarsObj.getBytesTotal(), 
loadvarsObj.getBytesLoaded());
+       check (loadvarsObj.getBytesLoaded() > 10);
        check_equals (this, loadvarsObj);
        check_equals(arguments.length, 1);
        check_equals(typeof(success), 'boolean');
@@ -163,7 +165,7 @@
                // Gnash insists in looking for an ending & char !!             
                check_equals(loadvarsObj['var3'], 'val3\n');
 
-               check_totals(70);
+               check_totals(72);
 
                play();
        }
@@ -178,7 +180,7 @@
        check_equals(arguments.length, 1);
        check_equals(typeof(src), 'string');
        check_equals(src.substr(0, 10), 'var1=val1&');
-       check_equals(src.substr(loadvarsObj.getBytesTotal()-10), 'var3=val3\n');
+       check_equals(src.substr(loadvarsObj.getBytesTotal()-13), 'var3=val3\n');
        check_equals(datareceived, 0);
        datareceived++; // we expecte it to be called only once ?
        note("LoadVars.onData called ("+datareceived+"), byte loaded: "

Index: testsuite/media/vars.txt
===================================================================
RCS file: /sources/gnash/gnash/testsuite/media/vars.txt,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- testsuite/media/vars.txt    11 Jan 2008 09:09:59 -0000      1.2
+++ testsuite/media/vars.txt    16 Apr 2008 23:07:15 -0000      1.3
@@ -1,4 +1,4 @@
-var1=val1&var2=val2&
+var1=val1&var2=val2&
 second line (should be discarded)
 second line (should be discarded)
 third line (should be discarded)




reply via email to

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