Unreviewed, rolling out r207297.
authorryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Oct 2016 19:21:35 +0000 (19:21 +0000)
committerryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Oct 2016 19:21:35 +0000 (19:21 +0000)
This change broke the iOS build.

Reverted changeset:

"Disable URLParser for non-Safari iOS and Mac apps for now"
https://bugs.webkit.org/show_bug.cgi?id=163397
http://trac.webkit.org/changeset/207297

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

Source/WebCore/ChangeLog
Source/WebCore/platform/URLParser.cpp
Source/WebCore/platform/URLParser.h
Tools/ChangeLog
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/WebKitTestRunner/ios/mainIOS.mm
Tools/WebKitTestRunner/mac/main.mm

index 46501c6..5155eba 100644 (file)
@@ -1,3 +1,15 @@
+2016-10-13  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r207297.
+
+        This change broke the iOS build.
+
+        Reverted changeset:
+
+        "Disable URLParser for non-Safari iOS and Mac apps for now"
+        https://bugs.webkit.org/show_bug.cgi?id=163397
+        http://trac.webkit.org/changeset/207297
+
 2016-10-13  Anders Carlsson  <andersca@apple.com>
 
         Get rid of the HistoryItemVector typedef
index eb54cb1..b2440fc 100644 (file)
@@ -1128,6 +1128,12 @@ URLParser::URLParser(const String& input, const URL& base, const TextEncoding& e
 template<typename CharacterType>
 void URLParser::parse(const CharacterType* input, const unsigned length, const URL& base, const TextEncoding& encoding)
 {
+#if PLATFORM(MAC)
+    static bool isMail = MacApplication::isAppleMail();
+#else
+    static bool isMail = false;
+#endif
+    
     URL_PARSER_LOG("Parsing URL <%s> base <%s> encoding <%s>", String(input, length).utf8().data(), base.string().utf8().data(), encoding.name());
     m_url = { };
     ASSERT(m_asciiBuffer.isEmpty());
@@ -1454,7 +1460,7 @@ void URLParser::parse(const CharacterType* input, const unsigned length, const U
                     } else {
                         m_url.m_userEnd = currentPosition(authorityOrHostBegin);
                         m_url.m_passwordEnd = m_url.m_userEnd;
-                        if (!parseHostAndPort(iterator)) {
+                        if (!parseHostAndPort(iterator, isMail)) {
                             failure();
                             return;
                         }
@@ -1476,7 +1482,7 @@ void URLParser::parse(const CharacterType* input, const unsigned length, const U
             do {
                 LOG_STATE("Host");
                 if (*c == '/' || *c == '?' || *c == '#') {
-                    if (!parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c))) {
+                    if (!parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c), isMail)) {
                         failure();
                         return;
                     }
@@ -1647,7 +1653,7 @@ void URLParser::parse(const CharacterType* input, const unsigned length, const U
                         state = State::Path;
                         break;
                     }
-                    if (!parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c))) {
+                    if (!parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c), isMail)) {
                         failure();
                         return;
                     }
@@ -1867,13 +1873,16 @@ void URLParser::parse(const CharacterType* input, const unsigned length, const U
             m_url.m_hostEnd = m_url.m_userStart;
             m_url.m_portEnd = m_url.m_userStart;
             m_url.m_pathEnd = m_url.m_userStart + 2;
-        } else if (!parseHostAndPort(authorityOrHostBegin)) {
+        } else if (!parseHostAndPort(authorityOrHostBegin, isMail)) {
             failure();
             return;
         } else {
-            syntaxViolation(c);
-            appendToASCIIBuffer('/');
-            m_url.m_pathEnd = m_url.m_portEnd + 1;
+            if (LIKELY(!isMail || m_urlIsSpecial)) {
+                syntaxViolation(c);
+                appendToASCIIBuffer('/');
+                m_url.m_pathEnd = m_url.m_portEnd + 1;
+            } else
+                m_url.m_pathEnd = m_url.m_portEnd;
         }
         m_url.m_pathAfterLastSlash = m_url.m_pathEnd;
         m_url.m_queryEnd = m_url.m_pathEnd;
@@ -1881,13 +1890,16 @@ void URLParser::parse(const CharacterType* input, const unsigned length, const U
         break;
     case State::Host:
         LOG_FINAL_STATE("Host");
-        if (!parseHostAndPort(authorityOrHostBegin)) {
+        if (!parseHostAndPort(authorityOrHostBegin, isMail)) {
             failure();
             return;
         }
-        syntaxViolation(c);
-        appendToASCIIBuffer('/');
-        m_url.m_pathEnd = m_url.m_portEnd + 1;
+        if (LIKELY(!isMail || m_urlIsSpecial)) {
+            syntaxViolation(c);
+            appendToASCIIBuffer('/');
+            m_url.m_pathEnd = m_url.m_portEnd + 1;
+        } else
+            m_url.m_pathEnd = m_url.m_portEnd;
         m_url.m_pathAfterLastSlash = m_url.m_pathEnd;
         m_url.m_queryEnd = m_url.m_pathEnd;
         m_url.m_fragmentEnd = m_url.m_pathEnd;
@@ -1941,7 +1953,7 @@ void URLParser::parse(const CharacterType* input, const unsigned length, const U
             break;
         }
 
-        if (!parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c))) {
+        if (!parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c), isMail)) {
             failure();
             return;
         }
@@ -2556,7 +2568,7 @@ bool URLParser::parsePort(CodePointIterator<CharacterType>& iterator)
 }
 
 template<typename CharacterType>
-bool URLParser::parseHostAndPort(CodePointIterator<CharacterType> iterator)
+bool URLParser::parseHostAndPort(CodePointIterator<CharacterType> iterator, const bool& isMail)
 {
     if (iterator.atEnd())
         return false;
@@ -2606,9 +2618,13 @@ bool URLParser::parseHostAndPort(CodePointIterator<CharacterType> iterator)
         }
         for (; hostIterator != iterator; ++hostIterator) {
             if (LIKELY(!isTabOrNewline(*hostIterator))) {
-                if (UNLIKELY(isASCIIUpper(*hostIterator)))
-                    syntaxViolation(hostIterator);
-                appendToASCIIBuffer(toASCIILower(*hostIterator));
+                if (UNLIKELY(isMail && !m_urlIsSpecial))
+                    appendToASCIIBuffer(*hostIterator);
+                else {
+                    if (UNLIKELY(isASCIIUpper(*hostIterator)))
+                        syntaxViolation(hostIterator);
+                    appendToASCIIBuffer(toASCIILower(*hostIterator));
+                }
             } else
                 syntaxViolation(hostIterator);
         }
@@ -2787,31 +2803,16 @@ bool URLParser::internalValuesConsistent(const URL& url)
     // It should be able to be deduced from m_isValid and m_string.length() to save memory.
 }
 
-enum class URLParserEnabled {
-    Undetermined,
-    Yes,
-    No
-};
-
-static URLParserEnabled urlParserEnabled = URLParserEnabled::Undetermined;
+static bool urlParserEnabled = true;
 
 void URLParser::setEnabled(bool enabled)
 {
-    urlParserEnabled = enabled ? URLParserEnabled::Yes : URLParserEnabled::No;
+    urlParserEnabled = enabled;
 }
 
 bool URLParser::enabled()
 {
-    if (urlParserEnabled == URLParserEnabled::Undetermined) {
-#if PLATFORM(MAC)
-        urlParserEnabled = MacApplication::isSafari() ? URLParserEnabled::Yes : URLParserEnabled::No;
-#elif PLATFORM(IOS)
-        urlParserEnabled = IOSApplication::isMobileSafari() ? URLParserEnabled::Yes : URLParserEnabled::No;
-#else
-        urlParserEnabled = URLParserEnabled::Yes;
-#endif
-    }
-    return urlParserEnabled == URLParserEnabled::Yes;
+    return urlParserEnabled;
 }
 
 } // namespace WebCore
index a7b2461..fd1eb3b 100644 (file)
@@ -60,7 +60,7 @@ private:
 
     template<typename CharacterType> void parse(const CharacterType*, const unsigned length, const URL&, const TextEncoding&);
     template<typename CharacterType> void parseAuthority(CodePointIterator<CharacterType>);
-    template<typename CharacterType> bool parseHostAndPort(CodePointIterator<CharacterType>);
+    template<typename CharacterType> bool parseHostAndPort(CodePointIterator<CharacterType>, const bool& isMail);
     template<typename CharacterType> bool parsePort(CodePointIterator<CharacterType>&);
 
     void failure();
index 970dfc5..299e4b9 100644 (file)
@@ -1,3 +1,15 @@
+2016-10-13  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r207297.
+
+        This change broke the iOS build.
+
+        Reverted changeset:
+
+        "Disable URLParser for non-Safari iOS and Mac apps for now"
+        https://bugs.webkit.org/show_bug.cgi?id=163397
+        http://trac.webkit.org/changeset/207297
+
 2016-10-13  Alex Christensen  <achristensen@webkit.org>
 
         Disable URLParser for non-Safari iOS and Mac apps for now
index 56d53d1..e2d8a87 100644 (file)
@@ -58,7 +58,6 @@
 #import <CoreFoundation/CoreFoundation.h>
 #import <JavaScriptCore/TestRunnerUtils.h>
 #import <WebCore/LogInitialization.h>
-#import <WebCore/URLParser.h>
 #import <WebKit/DOMElement.h>
 #import <WebKit/DOMExtensions.h>
 #import <WebKit/DOMRange.h>
@@ -1410,7 +1409,6 @@ void atexitFunction()
 
 int DumpRenderTreeMain(int argc, const char *argv[])
 {
-    WebCore::URLParser::setEnabled(true);
     atexit(atexitFunction);
 
 #if PLATFORM(IOS)
index 246a29a..3d0154c 100644 (file)
@@ -29,7 +29,6 @@
 #import "TestController.h"
 #import "UIKitSPI.h"
 #import <UIKit/UIKit.h>
-#import <WebCore/URLParser.h>
 
 static int _argc;
 static const char **_argv;
@@ -65,7 +64,6 @@ static const char **_argv;
 
 int main(int argc, const char* argv[])
 {
-    WebCore::URLParser::setEnabled(true);
     _argc = argc;
     _argv = argv;
 
index f1732da..38ab0a9 100644 (file)
@@ -29,7 +29,6 @@
 
 #import "PlatformWebView.h"
 #import "TestController.h"
-#import <WebCore/URLParser.h>
 
 static void setDefaultsToConsistentValuesForTesting()
 {
@@ -56,7 +55,6 @@ static void disableAppNapInUIProcess()
 
 int main(int argc, const char* argv[])
 {
-    WebCore::URLParser::setEnabled(true);
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     [NSApplication sharedApplication];
     setDefaultsToConsistentValuesForTesting();