- fix http://bugs.webkit.org/show_bug.cgi?id=16179 | <rdar://problem/5619399>
authorslewis@apple.com <slewis@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Dec 2007 22:05:15 +0000 (22:05 +0000)
committerslewis@apple.com <slewis@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Dec 2007 22:05:15 +0000 (22:05 +0000)
          Any attribute name start with a unicode which like #xx00(x could be any hex number[0-9a-f]) will cause HTMLTokenizer parse error
          Actually any unicode characters which great than 255 in attribute name will cause Webkit parse the attribute name wrong. So after comparing
          the same scenario in IE 6/7, FireFox 2/3, Opera, we should treat those characters as part of attribute name.

        * html/HTMLTokenizer.cpp:
        (WebCore::HTMLTokenizer::parseEntity): Handle Unicode Entity Name by using ASCII version of findEntity.
        (WebCore::HTMLTokenizer::parseTag): Let type of ptr match type of cBuffer.
        * html/HTMLTokenizer.h: Change type of cBuffer from char to UChar.

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

LayoutTests/ChangeLog
LayoutTests/fast/parser/test-unicode-characters-in-attribute-name-expected.txt [new file with mode: 0644]
LayoutTests/fast/parser/test-unicode-characters-in-attribute-name.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/html/HTMLTokenizer.cpp
WebCore/html/HTMLTokenizer.h
WebKitTools/Scripts/run-iexploder-tests
WebKitTools/Scripts/run-mangleme-tests

index 4f8362fd91dda94a5b6e0e917b7c3c6aaac933ce..777bab2247e61609edb82f52b4cac147afd56dc1 100644 (file)
@@ -1,3 +1,13 @@
+2007-12-20  johnnyding.webkit  <johnnyding.webkit@gmail.com>
+       
+        Reviewed by Alexey. Landed by Stephanie.
+
+        - bug http://bugs.webkit.org/show_bug.cgi?id=16179 | <rdar://problem/5619399>
+        Test for unicode characters which is great than 255 are in HTML attribute name
+
+        * fast/parser/test-unicode-characters-in-attribute-name-expected.txt: Added.
+        * fast/parser/test-unicode-characters-in-attribute-name.html: Added.
+
 2007-12-20  Eric Seidel  <eric@webkit.org>
 
         Reviewed by Nikolas Zimmermann.
diff --git a/LayoutTests/fast/parser/test-unicode-characters-in-attribute-name-expected.txt b/LayoutTests/fast/parser/test-unicode-characters-in-attribute-name-expected.txt
new file mode 100644 (file)
index 0000000..ea7d252
--- /dev/null
@@ -0,0 +1,6 @@
+All attributes of the content element are:
+
+0. id : content
+1.  title : http://www.315.com.cn/newwebsite/images0821/315_ca_03.gif
+2. la ng : zh-cn
+
diff --git a/LayoutTests/fast/parser/test-unicode-characters-in-attribute-name.html b/LayoutTests/fast/parser/test-unicode-characters-in-attribute-name.html
new file mode 100644 (file)
index 0000000..2c782c3
Binary files /dev/null and b/LayoutTests/fast/parser/test-unicode-characters-in-attribute-name.html differ
index 49e41dff49dfc1e261515d7cb463a463bf07808b..44ac1841a2690d6dbe3a8442f72783d6e1eba1db 100644 (file)
@@ -1,3 +1,18 @@
+2007-12-19  johnnyding.webkit  <johnnyding.webkit@gmail.com>
+
+        Reviewed by Alexey. Landed by Stephanie.
+
+        - fix http://bugs.webkit.org/show_bug.cgi?id=16179 | <rdar://problem/5619399>
+          Any attribute name start with a unicode which like #xx00(x could be any hex number[0-9a-f]) will cause HTMLTokenizer parse error
+          Actually any unicode characters which great than 255 in attribute name will cause Webkit parse the attribute name wrong. So after comparing 
+          the same scenario in IE 6/7, FireFox 2/3, Opera, we should treat those characters as part of attribute name.
+
+
+        * html/HTMLTokenizer.cpp:
+        (WebCore::HTMLTokenizer::parseEntity): Handle Unicode Entity Name by using ASCII version of findEntity.
+        (WebCore::HTMLTokenizer::parseTag): Let type of ptr match type of cBuffer.
+        * html/HTMLTokenizer.h: Change type of cBuffer from char to UChar.
+
 2007-12-20  Eric Seidel  <eric@webkit.org>
 
         Reviewed by Nikolas Zimmermann.
index 10c631d031071e6a197cfb8dd0b3fc891ba85cf6..2e5598643916ad54697f382ebede26595efecd9a 100644 (file)
@@ -770,7 +770,28 @@ HTMLTokenizer::State HTMLTokenizer::parseEntity(SegmentedString &src, UChar*& de
                 state.setEntityState(SearchSemicolon);
             if (state.entityState() == SearchSemicolon) {
                 if(cBufferPos > 1) {
-                    const Entity *e = findEntity(cBuffer, cBufferPos);
+                    // Since the maximum length of entity name is 9,
+                    // so a single char array which is allocated on
+                    // the stack, its length is 10, should be OK.
+                    // Also if we have an illegal character, we treat it
+                    // as illegal entity name.
+                    unsigned testedEntityNameLen = 0;
+                    char tmpEntityNameBuffer[10];
+
+                    ASSERT(cBufferPos < 10);
+                    for (; testedEntityNameLen < cBufferPos; ++testedEntityNameLen) {
+                        if (cBuffer[testedEntityNameLen] > 0x7e)
+                            break;
+                        tmpEntityNameBuffer[testedEntityNameLen] = cBuffer[testedEntityNameLen];
+                    }
+
+                    const Entity *e;
+
+                    if (testedEntityNameLen == cBufferPos)
+                        e = findEntity(tmpEntityNameBuffer, cBufferPos);
+                    else
+                        e = 0;
+
                     if(e)
                         EntityUnicodeValue = e->code;
 
@@ -870,7 +891,6 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString &src, State state)
                           state.setInComment(false);
                           src.advance(m_lineNumber);
                           if (!src.isEmpty())
-                              // cuts off high bits, which is okay
                               cBuffer[cBufferPos++] = *src;
                         }
                         else
@@ -879,7 +899,6 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString &src, State state)
                         m_cBufferPos = cBufferPos;
                         return state; // Finished parsing tag!
                     }
-                    // cuts off high bits, which is okay
                     cBuffer[cBufferPos++] = *src;
                     src.advance(m_lineNumber);
                     break;
@@ -909,7 +928,7 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString &src, State state)
             // as attribute names. ### judge if this causes problems
             if(finish || CBUFLEN == cBufferPos) {
                 bool beginTag;
-                char* ptr = cBuffer;
+                UChar* ptr = cBuffer;
                 unsigned int len = cBufferPos;
                 cBuffer[cBufferPos] = '\0';
                 if ((cBufferPos > 0) && (*ptr == '/')) {
index 56d936f4f52a841445b25f2b0cf7abbb2705498a..99a93f51b0b84d7c4a968899d4857abf3bf8d472 100644 (file)
@@ -343,7 +343,7 @@ private:
 // So any fixed number might be too small, but rather than rewriting all usage of this buffer
 // we'll just make it large enough to handle all imaginable cases.
 #define CBUFLEN 1024
-    char cBuffer[CBUFLEN + 2];
+    UChar cBuffer[CBUFLEN + 2];
     unsigned int m_cBufferPos;
 
     SegmentedString src;
index 6acff183b59d3f4f1035d438a1b8c28d2ce6dafe..05f2dc0d7dc7640d5d2d84daf05a44dc94fea732 100755 (executable)
@@ -130,13 +130,25 @@ sub openHTTPDIfNeeded()
     my $testDirectory = getcwd() . "/LayoutTests";
     my $iExploderDirectory = getcwd() . "/WebKitTools/iExploder";
     my $httpdPath = "/usr/sbin/httpd";
-    my $httpdConfig = "$testDirectory/http/conf/httpd.conf";
-    $httpdConfig = "$testDirectory/http/conf/apache2-httpd.conf" if `$httpdPath -v` =~ m|Apache/2|;
+    my $httpdConfig;
+    if (isCygwin()) {
+        my $windowsConfDirectory = "$testDirectory/http/conf/";
+        unless (-x "/usr/lib/apache/libphp4.dll") {
+            copy("$windowsConfDirectory/libphp4.dll", "/usr/lib/apache/libphp4.dll");
+            chmod(0755, "/usr/lib/apache/libphp4.dll");
+        }
+        $httpdConfig = "$windowsConfDirectory/cygwin-httpd.conf";
+    } else {
+        $httpdConfig = "$testDirectory/http/conf/httpd.conf";
+        $httpdConfig = "$testDirectory/http/conf/apache2-httpd.conf" if `$httpdPath -v` =~ m|Apache/2|;
+    }
     my $documentRoot = "$iExploderDirectory/htdocs";
     my $typesConfig = "$testDirectory/http/conf/mime.types";
     my $listen = "127.0.0.1:$httpdPort";
+    #my $absTestResultsDirectory = File::Spec->rel2abs(glob $testResultsDirectory);
+    my $sslCertificate = "$testDirectory/http/conf/webkit-httpd.pem";
 
-    open2(\*HTTPDIN, \*HTTPDOUT, $httpdPath, 
+    my @args = (
         "-f", "$httpdConfig",
         "-C", "DocumentRoot \"$documentRoot\"",
         "-C", "Listen $listen",
@@ -144,7 +156,14 @@ sub openHTTPDIfNeeded()
         "-c", "CustomLog \"/tmp/WebKit/access_log.txt\" common",
         "-c", "ErrorLog \"/tmp/WebKit/error_log.txt\"",
         # Apache wouldn't run CGIs with permissions==700 otherwise
-        "-c", "User \"#$<\"");
+        "-c", "User \"#$<\""
+    );
+
+    # FIXME: Enable this on Windows once <rdar://problem/5345985> is fixed
+    push(@args, "-c", "SSLCertificateFile \"$sslCertificate\"") unless isCygwin();
+
+    open2(\*HTTPDIN, \*HTTPDOUT, $httpdPath, @args);
+    
 
     my $retryCount = 20;
     while (system("/usr/bin/curl -q --silent --stderr - --output /dev/null $listen") && $retryCount) {
index 78b5d14f99c8ff82c3f311830a155e47e18e0f05..aae98b6e268bdfc30792f4b03b8e5559fbace0fb 100755 (executable)
@@ -74,7 +74,7 @@ if ($downloadTest) {
 } else {
     runSafari();
     print "Last generated tests:\n";
-    system "grep 'Mangle attempt' /tmp/WebKit/error_log.txt | tail -n -5 | awk ' {print \$4}'";
+    system "grep 'Mangle attempt' /tmp/WebKit/error_log.txt | tail -n -5 | awk ' {print \$12}'";
 }
 
 closeHTTPD();
@@ -104,7 +104,7 @@ sub runSafari()
     
     local %ENV;
     $ENV{DYLD_INSERT_LIBRARIES} = "/usr/lib/libgmalloc.dylib" if $guardMalloc;
-    system "WebKitTools/Scripts/run-safari", "-NSOpen", "/tmp/WebKit/redirect.html";
+    system "WebKitTools/Scripts/run-safari /tmp/WebKit/redirect.html";
 }
 
 sub openHTTPDIfNeeded()
@@ -133,13 +133,25 @@ sub openHTTPDIfNeeded()
     my $testDirectory = getcwd() . "/LayoutTests";
     my $manglemeDirectory = getcwd() . "/WebKitBuild/mangleme";
     my $httpdPath = "/usr/sbin/httpd";
-    my $httpdConfig = "$testDirectory/http/conf/httpd.conf";
-    $httpdConfig = "$testDirectory/http/conf/apache2-httpd.conf" if `$httpdPath -v` =~ m|Apache/2|;
+    my $httpdConfig;
+    if (isCygwin()) {
+        my $windowsConfDirectory = "$testDirectory/http/conf/";
+        unless (-x "/usr/lib/apache/libphp4.dll") {
+            copy("$windowsConfDirectory/libphp4.dll", "/usr/lib/apache/libphp4.dll");
+            chmod(0755, "/usr/lib/apache/libphp4.dll");
+        }
+        $httpdConfig = "$windowsConfDirectory/cygwin-httpd.conf";
+    } else {
+        $httpdConfig = "$testDirectory/http/conf/httpd.conf";
+        $httpdConfig = "$testDirectory/http/conf/apache2-httpd.conf" if `$httpdPath -v` =~ m|Apache/2|;
+    }
     my $documentRoot = "$manglemeDirectory";
     my $typesConfig = "$testDirectory/http/conf/mime.types";
     my $listen = "127.0.0.1:$httpdPort";
+    #my $absTestResultsDirectory = File::Spec->rel2abs(glob $testResultsDirectory);
+    my $sslCertificate = "$testDirectory/http/conf/webkit-httpd.pem";
 
-    open2(\*HTTPDIN, \*HTTPDOUT, $httpdPath, 
+    my @args = (
         "-f", "$httpdConfig",
         "-C", "DocumentRoot \"$documentRoot\"",
         "-C", "Listen $listen",
@@ -147,7 +159,14 @@ sub openHTTPDIfNeeded()
         "-c", "CustomLog \"/tmp/WebKit/access_log.txt\" common",
         "-c", "ErrorLog \"/tmp/WebKit/error_log.txt\"",
         # Apache wouldn't run CGIs with permissions==700 otherwise
-        "-c", "User \"#$<\"");
+        "-c", "User \"#$<\""
+    );
+
+    # FIXME: Enable this on Windows once <rdar://problem/5345985> is fixed
+    push(@args, "-c", "SSLCertificateFile \"$sslCertificate\"") unless isCygwin();
+
+    open2(\*HTTPDIN, \*HTTPDOUT, $httpdPath, @args);
+
 
     my $retryCount = 20;
     while (system("/usr/bin/curl -q --silent --stderr - --output /dev/null $listen") && $retryCount) {