Title: [207268] trunk/Source/WebCore
Revision
207268
Author
achristen...@apple.com
Date
2016-10-12 19:14:30 -0700 (Wed, 12 Oct 2016)

Log Message

Mail needs nonspecial URLs to keep case in host and not have slash after host
https://bugs.webkit.org/show_bug.cgi?id=163373

Reviewed by Saam Barati.
        
Mail uses urls like scheme://HoSt which were not changed when canonicalized 
before enabling the URLParser but now are canonicalized to scheme://host/
I manually verified this fixes the issue.
This should be reverted once Mail will accept modern canonicalized URLs.

* platform/URLParser.cpp:
(WebCore::URLParser::parse):
(WebCore::URLParser::parseHostAndPort):
* platform/URLParser.h:
If the application is mail and the scheme is nonspecial, don't make the host lower case and don't add a slash after the host.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (207267 => 207268)


--- trunk/Source/WebCore/ChangeLog	2016-10-13 02:05:44 UTC (rev 207267)
+++ trunk/Source/WebCore/ChangeLog	2016-10-13 02:14:30 UTC (rev 207268)
@@ -1,3 +1,21 @@
+2016-10-12  Alex Christensen  <achristen...@webkit.org>
+
+        Mail needs nonspecial URLs to keep case in host and not have slash after host
+        https://bugs.webkit.org/show_bug.cgi?id=163373
+
+        Reviewed by Saam Barati.
+        
+        Mail uses urls like scheme://HoSt which were not changed when canonicalized 
+        before enabling the URLParser but now are canonicalized to scheme://host/
+        I manually verified this fixes the issue.
+        This should be reverted once Mail will accept modern canonicalized URLs.
+
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parse):
+        (WebCore::URLParser::parseHostAndPort):
+        * platform/URLParser.h:
+        If the application is mail and the scheme is nonspecial, don't make the host lower case and don't add a slash after the host.
+
 2016-10-11  Dean Jackson  <d...@apple.com>
 
         Add preliminary support for extended colors to WebCore::Color

Modified: trunk/Source/WebCore/platform/URLParser.cpp (207267 => 207268)


--- trunk/Source/WebCore/platform/URLParser.cpp	2016-10-13 02:05:44 UTC (rev 207267)
+++ trunk/Source/WebCore/platform/URLParser.cpp	2016-10-13 02:14:30 UTC (rev 207268)
@@ -27,6 +27,7 @@
 #include "URLParser.h"
 
 #include "Logging.h"
+#include "RuntimeApplicationChecks.h"
 #include <array>
 #include <unicode/uidna.h>
 #include <unicode/utypes.h>
@@ -1127,6 +1128,12 @@
 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());
@@ -1453,7 +1460,7 @@
                     } else {
                         m_url.m_userEnd = currentPosition(authorityOrHostBegin);
                         m_url.m_passwordEnd = m_url.m_userEnd;
-                        if (!parseHostAndPort(iterator)) {
+                        if (!parseHostAndPort(iterator, isMail)) {
                             failure();
                             return;
                         }
@@ -1475,7 +1482,7 @@
             do {
                 LOG_STATE("Host");
                 if (*c == '/' || *c == '?' || *c == '#') {
-                    if (!parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c))) {
+                    if (!parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c), isMail)) {
                         failure();
                         return;
                     }
@@ -1646,7 +1653,7 @@
                         state = State::Path;
                         break;
                     }
-                    if (!parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c))) {
+                    if (!parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c), isMail)) {
                         failure();
                         return;
                     }
@@ -1866,13 +1873,16 @@
             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;
@@ -1880,13 +1890,16 @@
         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;
@@ -1940,7 +1953,7 @@
             break;
         }
 
-        if (!parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c))) {
+        if (!parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c), isMail)) {
             failure();
             return;
         }
@@ -2555,7 +2568,7 @@
 }
 
 template<typename CharacterType>
-bool URLParser::parseHostAndPort(CodePointIterator<CharacterType> iterator)
+bool URLParser::parseHostAndPort(CodePointIterator<CharacterType> iterator, const bool& isMail)
 {
     if (iterator.atEnd())
         return false;
@@ -2605,9 +2618,13 @@
         }
         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);
         }

Modified: trunk/Source/WebCore/platform/URLParser.h (207267 => 207268)


--- trunk/Source/WebCore/platform/URLParser.h	2016-10-13 02:05:44 UTC (rev 207267)
+++ trunk/Source/WebCore/platform/URLParser.h	2016-10-13 02:14:30 UTC (rev 207268)
@@ -60,7 +60,7 @@
 
     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();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to