WebCore:
authorbdakin <bdakin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Jan 2007 21:57:23 +0000 (21:57 +0000)
committerbdakin <bdakin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Jan 2007 21:57:23 +0000 (21:57 +0000)
        Reviewed by Maciej and Darin.

        Fix for <rdar://problem/4702420> REGRESSION: Null characters need
        to be stripped from text nodes (townhall.com)

        This was a regression from the fix for <rdar://problem/3727939>
        Safari strips \0 characters from HTML tags making them valid, which
        was fixed with r12652. We still need to strip null characters in
        text nodes.

        * html/HTMLTokenizer.cpp:
        (WebCore::HTMLTokenizer::write): No behavior change here, this is
        just to make Darin happy.
        (WebCore::HTMLTokenizer::processToken): Call into StringImpl's new
        createStrippingNull function instead of the normal StringImpl
        constructor.
        * platform/StringImpl.cpp:
        (WebCore::StringImpl::createStrippingNull): Strip null.
        * platform/StringImpl.h:

LayoutTests:
        Reviewed by Maciej and Darin.

        New layout tests and some updates results for the fix for <rdar://
        problem/4702420> REGRESSION: Null characters need to be stripped
        from text nodes (townhall.com)

        * fast/dom/stripNullFromTextNodes-expected.checksum: Added.
        * fast/dom/stripNullFromTextNodes-expected.png: Added.
        * fast/dom/stripNullFromTextNodes-expected.txt: Added.
        * fast/dom/stripNullFromTextNodes.html: Added.
        * fast/js/null-char-in-string-expected.txt: New results.
        * fast/text/stripNullFromText-expected.checksum: Added.
        * fast/text/stripNullFromText-expected.png: Added.
        * fast/text/stripNullFromText-expected.txt: Added.
        * fast/text/stripNullFromText.html: Added.
        * tables/mozilla/images/adforce_imgis_com-expected.txt: New
        results.
        * tables/mozilla_expected_failures/images/adforce_imgis_com-
        expected.checksum: Removed. This is the same test as the one above.
        The same test was in two places.
        * tables/mozilla_expected_failures/images/adforce_imgis_com-
        expected.png: Removed.
        * tables/mozilla_expected_failures/images/adforce_imgis_com-
        expected.txt: Removed.
        * tables/mozilla_expected_failures/images/adforce_imgis_com.html:
        Removed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@18988 268f45cc-cd09-0410-ab3c-d52691b4dbfc

20 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/stripNullFromTextNodes-expected.checksum [new file with mode: 0644]
LayoutTests/fast/dom/stripNullFromTextNodes-expected.png [new file with mode: 0644]
LayoutTests/fast/dom/stripNullFromTextNodes-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/stripNullFromTextNodes.html [new file with mode: 0644]
LayoutTests/fast/js/null-char-in-string-expected.txt
LayoutTests/fast/text/stripNullFromText-expected.checksum [new file with mode: 0644]
LayoutTests/fast/text/stripNullFromText-expected.png [new file with mode: 0644]
LayoutTests/fast/text/stripNullFromText-expected.txt [new file with mode: 0644]
LayoutTests/fast/text/stripNullFromText.html [new file with mode: 0644]
LayoutTests/tables/mozilla/images/adforce_imgis_com-expected.txt
LayoutTests/tables/mozilla_expected_failures/images/adforce_imgis_com-expected.checksum [deleted file]
LayoutTests/tables/mozilla_expected_failures/images/adforce_imgis_com-expected.png [deleted file]
LayoutTests/tables/mozilla_expected_failures/images/adforce_imgis_com-expected.txt [deleted file]
LayoutTests/tables/mozilla_expected_failures/images/adforce_imgis_com.html [deleted file]
WebCore/ChangeLog
WebCore/html/HTMLTokenizer.cpp
WebCore/platform/StringImpl.cpp
WebCore/platform/StringImpl.h
WebKit/WebKit.xcodeproj/project.pbxproj

index 5134ebd..f1084f7 100644 (file)
@@ -1,3 +1,32 @@
+2007-01-19  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Maciej and Darin.
+
+        New layout tests and some updates results for the fix for <rdar://
+        problem/4702420> REGRESSION: Null characters need to be stripped 
+        from text nodes (townhall.com)
+
+        * fast/dom/stripNullFromTextNodes-expected.checksum: Added.
+        * fast/dom/stripNullFromTextNodes-expected.png: Added.
+        * fast/dom/stripNullFromTextNodes-expected.txt: Added.
+        * fast/dom/stripNullFromTextNodes.html: Added.
+        * fast/js/null-char-in-string-expected.txt: New results.
+        * fast/text/stripNullFromText-expected.checksum: Added.
+        * fast/text/stripNullFromText-expected.png: Added.
+        * fast/text/stripNullFromText-expected.txt: Added.
+        * fast/text/stripNullFromText.html: Added.
+        * tables/mozilla/images/adforce_imgis_com-expected.txt: New 
+        results.
+        * tables/mozilla_expected_failures/images/adforce_imgis_com-
+        expected.checksum: Removed. This is the same test as the one above. 
+        The same test was in two places.
+        * tables/mozilla_expected_failures/images/adforce_imgis_com-
+        expected.png: Removed.
+        * tables/mozilla_expected_failures/images/adforce_imgis_com-
+        expected.txt: Removed.
+        * tables/mozilla_expected_failures/images/adforce_imgis_com.html: 
+        Removed.
+
 2007-01-19  Nikolas Zimmermann  <zimmermann@kde.org>
 
         Reviewed by Eric.
diff --git a/LayoutTests/fast/dom/stripNullFromTextNodes-expected.checksum b/LayoutTests/fast/dom/stripNullFromTextNodes-expected.checksum
new file mode 100644 (file)
index 0000000..a1a9ab4
--- /dev/null
@@ -0,0 +1 @@
+c932173cc509a9e9aefdf1294d1454a4
\ No newline at end of file
diff --git a/LayoutTests/fast/dom/stripNullFromTextNodes-expected.png b/LayoutTests/fast/dom/stripNullFromTextNodes-expected.png
new file mode 100644 (file)
index 0000000..eb8fd80
Binary files /dev/null and b/LayoutTests/fast/dom/stripNullFromTextNodes-expected.png differ
diff --git a/LayoutTests/fast/dom/stripNullFromTextNodes-expected.txt b/LayoutTests/fast/dom/stripNullFromTextNodes-expected.txt
new file mode 100644 (file)
index 0000000..f05d664
--- /dev/null
@@ -0,0 +1,13 @@
+layer at (0,0) size 1072x585
+  RenderView at (0,0) size 800x585
+layer at (0,0) size 1072x585
+  RenderBlock {HTML} at (0,0) size 800x585
+    RenderBody {BODY} at (8,8) size 784x564
+      RenderBlock {DIV} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 31x18
+          text run at (0,0) width 31: "hello"
+      RenderBlock {PRE} at (0,31) size 784x15
+        RenderText {#text} at (0,0) size 1048x15
+          text run at (0,0) width 1048: "The null characters should be stripped out of the sting above and it should have a length of 5. And the DOM thinks the length is..."
+        RenderText {#text} at (1048,0) size 16x15
+          text run at (1048,0) width 16: "5!"
diff --git a/LayoutTests/fast/dom/stripNullFromTextNodes.html b/LayoutTests/fast/dom/stripNullFromTextNodes.html
new file mode 100644 (file)
index 0000000..32192e9
Binary files /dev/null and b/LayoutTests/fast/dom/stripNullFromTextNodes.html differ
index e7cf546..8443757 100644 (file)
@@ -3,4 +3,8 @@ This test checks that null characters are allowed in JavaScript strings, rather
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS String("
+PASS String("").length is 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/text/stripNullFromText-expected.checksum b/LayoutTests/fast/text/stripNullFromText-expected.checksum
new file mode 100644 (file)
index 0000000..efe6d83
--- /dev/null
@@ -0,0 +1 @@
+1e70565686519d04dd81426fe3ab3bc4
\ No newline at end of file
diff --git a/LayoutTests/fast/text/stripNullFromText-expected.png b/LayoutTests/fast/text/stripNullFromText-expected.png
new file mode 100644 (file)
index 0000000..820eddf
Binary files /dev/null and b/LayoutTests/fast/text/stripNullFromText-expected.png differ
diff --git a/LayoutTests/fast/text/stripNullFromText-expected.txt b/LayoutTests/fast/text/stripNullFromText-expected.txt
new file mode 100644 (file)
index 0000000..51694f6
--- /dev/null
@@ -0,0 +1,6 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 784x2 [border: (1px solid #FF0000)]
diff --git a/LayoutTests/fast/text/stripNullFromText.html b/LayoutTests/fast/text/stripNullFromText.html
new file mode 100644 (file)
index 0000000..d37a9fa
Binary files /dev/null and b/LayoutTests/fast/text/stripNullFromText.html differ
index c9ab782..9f1e649 100644 (file)
@@ -4,4 +4,4 @@ layer at (0,0) size 800x600
   RenderBlock {HTML} at (0,0) size 800x600
     RenderBody {BODY} at (8,8) size 784x584
       RenderText {#text} at (0,0) size 665x18
-        text run at (0,0) width 665: "GIF89a\x{D4}\x{1}<\x{0}\x{20AC}\x{0}\x{0}\x{0}\x{0}\x{7F}\x{0}\x{0}\x{0}!\x{FF}\x{B}NETSCAPE2.0\x{3}\x{1}\x{0}\x{0}\x{0}!\x{F9}\x{4}\x{4}<\x{0}\x{0}\x{0},\x{0}\x{0}\x{0}\x{0}\x{D4}\x{1}<\x{0}\x{201A}\x{0}\x{0}\x{7F}\x{FF}\x{FF}\x{0}\x{FF}\x{FF}\x{FF}\x{DF}\x{DF}\x{DF}\x{BF}\x{BF}\x{BF}\x{7F}\x{7F}\x{7F}\x{0}\x{0}\x{0}\x{0}\x{0}\x{0}\x{3}\x{FF}8\x{BA}\x{DC}\x{FE}0\x{CA}I\x{AB}\x{BD}8\x{EB}\x{CD}\x{BB}\x{FF}`(\x{17D}di*\x{C6} \x{AC}l\x{EB}\x{BE}p,\x{CF}tm\x{DF}x\x{AE}\x{EF}|\x{EF}\x{FF}\x{C0} pH,"
+        text run at (0,0) width 665: "GIF89a\x{D4}\x{1}<\x{20AC}\x{7F}!\x{FF}\x{B}NETSCAPE2.0\x{3}\x{1}!\x{F9}\x{4}\x{4}<,\x{D4}\x{1}<\x{201A}\x{7F}\x{FF}\x{FF}\x{FF}\x{FF}\x{FF}\x{DF}\x{DF}\x{DF}\x{BF}\x{BF}\x{BF}\x{7F}\x{7F}\x{7F}\x{3}\x{FF}8\x{BA}\x{DC}\x{FE}0\x{CA}I\x{AB}\x{BD}8\x{EB}\x{CD}\x{BB}\x{FF}`(\x{17D}di*\x{C6} \x{AC}l\x{EB}\x{BE}p,\x{CF}tm\x{DF}x\x{AE}\x{EF}|\x{EF}\x{FF}\x{C0} pH,"
diff --git a/LayoutTests/tables/mozilla_expected_failures/images/adforce_imgis_com-expected.checksum b/LayoutTests/tables/mozilla_expected_failures/images/adforce_imgis_com-expected.checksum
deleted file mode 100644 (file)
index a871de3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-5f640b01fb244620bf1ae7cff7c407ed
\ No newline at end of file
diff --git a/LayoutTests/tables/mozilla_expected_failures/images/adforce_imgis_com-expected.png b/LayoutTests/tables/mozilla_expected_failures/images/adforce_imgis_com-expected.png
deleted file mode 100644 (file)
index 2312d50..0000000
Binary files a/LayoutTests/tables/mozilla_expected_failures/images/adforce_imgis_com-expected.png and /dev/null differ
diff --git a/LayoutTests/tables/mozilla_expected_failures/images/adforce_imgis_com-expected.txt b/LayoutTests/tables/mozilla_expected_failures/images/adforce_imgis_com-expected.txt
deleted file mode 100644 (file)
index c9ab782..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x584
-      RenderText {#text} at (0,0) size 665x18
-        text run at (0,0) width 665: "GIF89a\x{D4}\x{1}<\x{0}\x{20AC}\x{0}\x{0}\x{0}\x{0}\x{7F}\x{0}\x{0}\x{0}!\x{FF}\x{B}NETSCAPE2.0\x{3}\x{1}\x{0}\x{0}\x{0}!\x{F9}\x{4}\x{4}<\x{0}\x{0}\x{0},\x{0}\x{0}\x{0}\x{0}\x{D4}\x{1}<\x{0}\x{201A}\x{0}\x{0}\x{7F}\x{FF}\x{FF}\x{0}\x{FF}\x{FF}\x{FF}\x{DF}\x{DF}\x{DF}\x{BF}\x{BF}\x{BF}\x{7F}\x{7F}\x{7F}\x{0}\x{0}\x{0}\x{0}\x{0}\x{0}\x{3}\x{FF}8\x{BA}\x{DC}\x{FE}0\x{CA}I\x{AB}\x{BD}8\x{EB}\x{CD}\x{BB}\x{FF}`(\x{17D}di*\x{C6} \x{AC}l\x{EB}\x{BE}p,\x{CF}tm\x{DF}x\x{AE}\x{EF}|\x{EF}\x{FF}\x{C0} pH,"
diff --git a/LayoutTests/tables/mozilla_expected_failures/images/adforce_imgis_com.html b/LayoutTests/tables/mozilla_expected_failures/images/adforce_imgis_com.html
deleted file mode 100644 (file)
index 3076258..0000000
Binary files a/LayoutTests/tables/mozilla_expected_failures/images/adforce_imgis_com.html and /dev/null differ
index b16cb19..1a0e915 100644 (file)
@@ -1,3 +1,25 @@
+2007-01-19  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Maciej and Darin.
+
+        Fix for <rdar://problem/4702420> REGRESSION: Null characters need 
+        to be stripped from text nodes (townhall.com)
+
+        This was a regression from the fix for <rdar://problem/3727939>
+        Safari strips \0 characters from HTML tags making them valid, which
+        was fixed with r12652. We still need to strip null characters in
+        text nodes.
+
+        * html/HTMLTokenizer.cpp:
+        (WebCore::HTMLTokenizer::write): No behavior change here, this is
+        just to make Darin happy.
+        (WebCore::HTMLTokenizer::processToken): Call into StringImpl's new 
+        createStrippingNull function instead of the normal StringImpl 
+        constructor.
+        * platform/StringImpl.cpp:
+        (WebCore::StringImpl::createStrippingNull): Strip null.
+        * platform/StringImpl.h:
+
 2007-01-19  David Kilzer  <ddkilzer@webkit.org>
 
         Reviewed by NOBODY (no-svg build fix).
index 80038e3..6b58818 100644 (file)
@@ -1408,7 +1408,7 @@ bool HTMLTokenizer::write(const SegmentedString& str, bool appendData)
             ++src;
         } else {
             state.setDiscardLF(false);
-            *dest++ = *src;
+            *dest++ = cc;
             ++src;
         }
     }
@@ -1544,7 +1544,7 @@ PassRefPtr<Node> HTMLTokenizer::processToken()
         }
 
 #endif
-        currToken.text = new StringImpl( buffer, dest - buffer );
+        currToken.text = StringImpl::createStrippingNull(buffer, dest - buffer);
         if (currToken.tagName != commentAtom)
             currToken.tagName = textAtom;
     } else if (currToken.tagName == nullAtom) {
index af35fd4..f11995a 100644 (file)
@@ -1170,6 +1170,23 @@ StringImpl::StringImpl(const UString& str)
     init(reinterpret_cast<const UChar*>(str.data()), str.size());
 }
 
+PassRefPtr<StringImpl> StringImpl::createStrippingNull(const UChar* str, unsigned len)
+{
+    StringImpl* result = new StringImpl;
+    if (!len || !str)
+        return result;
+    
+    UChar* strippedCopy = newUCharVector(len);
+    int strippedLength = 0;
+    for (unsigned i = 0; i < len; i++)
+        if (UChar c = str[i])
+            strippedCopy[strippedLength++] = c;
+
+    result->m_data = strippedCopy;
+    result->m_length = strippedLength;
+    return result;
+}
+
 StringImpl* StringImpl::newUninitialized(size_t length, UChar*& characterBuffer)
 {
     StringImpl* result = new StringImpl;
index 5f691ed..ed04b56 100644 (file)
@@ -64,6 +64,7 @@ public:
     StringImpl(const KJS::UString&);
     ~StringImpl();
 
+    static PassRefPtr<StringImpl> createStrippingNull(const UChar*, unsigned len);
     static StringImpl* newUninitialized(size_t length, UChar*& characterBuffer);
     static StringImpl* adopt(Vector<UChar>&);
 
index 26e80f0..7b7dc1c 100644 (file)
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */;
-                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
                        productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
                        projectDirPath = "";
                        projectRoot = "";
-                       shouldCheckCompatibility = 1;
                        targets = (
                                9398100A0824BF01008DF038 /* WebKit */,
                        );