Changeset 236674 in webkit
- Timestamp:
- Oct 1, 2018, 11:16:33 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r236673 r236674 1 2018-10-01 Alex Christensen <achristensen@webkit.org> 2 3 URL should not use TextEncoding internally 4 https://bugs.webkit.org/show_bug.cgi?id=190111 5 6 Reviewed by Andy Estes. 7 8 That dependency makes it impossible to move or use elsewhere. 9 Using TextEncoding was overkill because we know the credentials are UTF-8 percent-encoded in a parsed URL. 10 No change in behavior as verified by new API tests. 11 12 * page/SecurityOrigin.cpp: 13 * page/csp/ContentSecurityPolicySourceList.cpp: 14 * platform/URL.cpp: 15 (WebCore::decodeEscapeSequencesFromParsedURL): 16 (WebCore::URL::user const): 17 (WebCore::URL::pass const): 18 (WebCore::URL::fileSystemPath const): 19 (WebCore::decodeURLEscapeSequences): Deleted. 20 * platform/URL.h: 21 * platform/network/DataURLDecoder.cpp: 22 * platform/text/TextEncoding.cpp: 23 (WebCore::decodeURLEscapeSequences): 24 * platform/text/TextEncoding.h: 25 1 26 2018-10-01 Simon Pieters <zcorpan@gmail.com> 2 27 -
trunk/Source/WebCore/page/SecurityOrigin.cpp
r233122 r236674 35 35 #include "SchemeRegistry.h" 36 36 #include "SecurityPolicy.h" 37 #include "TextEncoding.h" 37 38 #include "ThreadableBlobRegistry.h" 38 39 #include <wtf/MainThread.h> -
trunk/Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp
r235560 r236674 31 31 #include "ContentSecurityPolicyDirectiveNames.h" 32 32 #include "ParsingUtilities.h" 33 #include "TextEncoding.h" 33 34 #include "URL.h" 34 35 #include <wtf/ASCIICType.h> -
trunk/Source/WebCore/platform/URL.cpp
r236565 r236674 28 28 #include "URL.h" 29 29 30 #include "DecodeEscapeSequences.h"31 #include "TextEncoding.h"32 30 #include "URLParser.h" 33 31 #include <stdio.h> … … 188 186 } 189 187 188 static String decodeEscapeSequencesFromParsedURL(StringView input) 189 { 190 auto inputLength = input.length(); 191 if (!inputLength) 192 return emptyString(); 193 Vector<LChar> percentDecoded; 194 percentDecoded.reserveInitialCapacity(inputLength); 195 for (unsigned i = 0; i < inputLength; ++i) { 196 if (input[i] == '%' 197 && inputLength > 2 198 && i < inputLength - 2 199 && isASCIIHexDigit(input[i + 1]) 200 && isASCIIHexDigit(input[i + 2])) { 201 percentDecoded.uncheckedAppend(toASCIIHexValue(input[i + 1], input[i + 2])); 202 i += 2; 203 } else 204 percentDecoded.uncheckedAppend(input[i]); 205 } 206 return String::fromUTF8(percentDecoded.data(), percentDecoded.size()); 207 } 208 190 209 String URL::user() const 191 210 { 192 return decode URLEscapeSequences(m_string.substring(m_userStart, m_userEnd - m_userStart));211 return decodeEscapeSequencesFromParsedURL(StringView(m_string).substring(m_userStart, m_userEnd - m_userStart)); 193 212 } 194 213 … … 198 217 return String(); 199 218 200 return decode URLEscapeSequences(m_string.substring(m_userEnd + 1, m_passwordEnd - m_userEnd - 1));219 return decodeEscapeSequencesFromParsedURL(StringView(m_string).substring(m_userEnd + 1, m_passwordEnd - m_userEnd - 1)); 201 220 } 202 221 … … 239 258 return String(); 240 259 241 return decode URLEscapeSequences(path());260 return decodeEscapeSequencesFromParsedURL(StringView(path())); 242 261 } 243 262 … … 657 676 URLParser parser(makeString(StringView(m_string).left(m_hostEnd + m_portLength), percentEncodeCharacters(path, questionMarkOrNumberSign), StringView(m_string).substring(m_pathEnd))); 658 677 *this = parser.result(); 659 }660 661 String decodeURLEscapeSequences(const String& string)662 {663 if (string.isEmpty())664 return string;665 return decodeEscapeSequences<URLEscapeSequence>(string, UTF8Encoding());666 }667 668 String decodeURLEscapeSequences(const String& string, const TextEncoding& encoding)669 {670 if (string.isEmpty())671 return string;672 return decodeEscapeSequences<URLEscapeSequence>(string, encoding);673 678 } 674 679 -
trunk/Source/WebCore/platform/URL.h
r236565 r236674 129 129 // Unlike user() and pass(), these functions don't decode escape sequences. 130 130 // This is necessary for accurate round-tripping, because encoding doesn't encode '%' characters. 131 String encodedUser() const;132 String encodedPass() const;131 WEBCORE_EXPORT String encodedUser() const; 132 WEBCORE_EXPORT String encodedPass() const; 133 133 134 134 WEBCORE_EXPORT String baseAsString() const; … … 303 303 String mimeTypeFromDataURL(const String& url); 304 304 305 // Unescapes the given string using URL escaping rules, given an optional306 // encoding (defaulting to UTF-8 otherwise). DANGER: If the URL has "%00"307 // in it, the resulting string will have embedded null characters!308 WEBCORE_EXPORT String decodeURLEscapeSequences(const String&);309 class TextEncoding;310 String decodeURLEscapeSequences(const String&, const TextEncoding&);311 312 305 // FIXME: This is a wrong concept to expose, different parts of a URL need different escaping per the URL Standard. 313 306 WEBCORE_EXPORT String encodeWithURLEscapeSequences(const String&); -
trunk/Source/WebCore/platform/network/DataURLDecoder.cpp
r233122 r236674 30 30 #include "HTTPParsers.h" 31 31 #include "SharedBuffer.h" 32 #include "TextEncoding.h" 32 33 #include "URL.h" 33 34 #include <wtf/MainThread.h> -
trunk/Source/WebCore/platform/text/TextEncoding.cpp
r236565 r236674 29 29 #include "TextEncoding.h" 30 30 31 #include "DecodeEscapeSequences.h" 31 32 #include "TextCodec.h" 32 33 #include "TextEncodingRegistry.h" … … 219 220 } 220 221 222 String decodeURLEscapeSequences(const String& string, const TextEncoding& encoding) 223 { 224 if (string.isEmpty()) 225 return string; 226 return decodeEscapeSequences<URLEscapeSequence>(string, encoding); 227 } 228 221 229 } // namespace WebCore -
trunk/Source/WebCore/platform/text/TextEncoding.h
r236565 r236674 73 73 WEBCORE_EXPORT const TextEncoding& WindowsLatin1Encoding(); 74 74 75 // Unescapes the given string using URL escaping rules. 76 // DANGER: If the URL has "%00" in it, 77 // the resulting string will have embedded null characters! 78 WEBCORE_EXPORT String decodeURLEscapeSequences(const String&, const TextEncoding& = UTF8Encoding()); 79 75 80 inline String TextEncoding::decode(const char* characters, size_t length) const 76 81 { -
trunk/Source/WebKit/ChangeLog
r236671 r236674 1 2018-10-01 Alex Christensen <achristensen@webkit.org> 2 3 URL should not use TextEncoding internally 4 https://bugs.webkit.org/show_bug.cgi?id=190111 5 6 Reviewed by Andy Estes. 7 8 * UIProcess/WebInspectorProxy.cpp: 9 1 10 2018-10-01 Jeremy Jones <jeremyj@apple.com> 2 11 -
trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp
r236344 r236674 41 41 #include <WebCore/SharedBuffer.h> 42 42 #include <WebCore/SoupNetworkSession.h> 43 #include <WebCore/TextEncoding.h> 43 44 #include <wtf/MainThread.h> 44 45 #include <wtf/glib/RunLoopSourcePriority.h> -
trunk/Source/WebKit/UIProcess/API/glib/WebKitFileChooserRequest.cpp
r224371 r236674 27 27 #include "WebOpenPanelResultListenerProxy.h" 28 28 #include <WebCore/FileSystem.h> 29 #include <WebCore/TextEncoding.h> 29 30 #include <WebCore/URL.h> 30 31 #include <glib/gi18n-lib.h> -
trunk/Source/WebKit/UIProcess/WebInspectorProxy.cpp
r235265 r236674 42 42 #include "WebProcessProxy.h" 43 43 #include <WebCore/NotImplemented.h> 44 #include <WebCore/TextEncoding.h> 44 45 #include <wtf/SetForScope.h> 45 46 -
trunk/Source/WebKit/WebProcess/Plugins/PluginView.cpp
r235205 r236674 68 68 #include <WebCore/SecurityPolicy.h> 69 69 #include <WebCore/Settings.h> 70 #include <WebCore/TextEncoding.h> 70 71 #include <WebCore/UserGestureIndicator.h> 71 72 #include <wtf/CompletionHandler.h> -
trunk/Source/WebKitLegacy/mac/ChangeLog
r236624 r236674 1 2018-10-01 Alex Christensen <achristensen@webkit.org> 2 3 URL should not use TextEncoding internally 4 https://bugs.webkit.org/show_bug.cgi?id=190111 5 6 Reviewed by Andy Estes. 7 8 * Misc/WebNSURLExtras.mm: 9 1 10 2018-09-28 Jer Noble <jer.noble@apple.com> 2 11 -
trunk/Source/WebKitLegacy/mac/Misc/WebNSURLExtras.mm
r222896 r236674 36 36 #import <WebCore/URL.h> 37 37 #import <WebCore/LoaderNSURLExtras.h> 38 #import <WebCore/TextEncoding.h> 38 39 #import <WebCore/WebCoreNSURLExtras.h> 39 40 #import <wtf/Assertions.h> -
trunk/Source/WebKitLegacy/win/WebDownloadCurl.cpp
r225998 r236674 51 51 #include <WebCore/ResourceRequest.h> 52 52 #include <WebCore/ResourceResponse.h> 53 #include <WebCore/TextEncoding.h> 53 54 54 55 using namespace WebCore; -
trunk/Tools/ChangeLog
r236667 r236674 1 2018-10-01 Alex Christensen <achristensen@webkit.org> 2 3 URL should not use TextEncoding internally 4 https://bugs.webkit.org/show_bug.cgi?id=190111 5 6 Reviewed by Andy Estes. 7 8 * TestWebKitAPI/Tests/WebCore/URLParser.cpp: 9 (TestWebKitAPI::testUserPass): 10 (TestWebKitAPI::TEST_F): 11 1 12 2018-10-01 Daniel Bates <dabates@apple.com> 2 13 -
trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp
r236565 r236674 501 501 // and Firefox fails the web platform test differently. Maybe the web platform test ought to be changed. 502 502 checkURL("http://:@host", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); 503 } 504 505 static void testUserPass(const String& value, const String& decoded, const String& encoded) 506 { 507 URL userURL(URL(), makeString("http://", value, "@example.com/")); 508 URL passURL(URL(), makeString("http://user:", value, "@example.com/")); 509 EXPECT_EQ(encoded, userURL.encodedUser()); 510 EXPECT_EQ(encoded, passURL.encodedPass()); 511 EXPECT_EQ(decoded, userURL.user()); 512 EXPECT_EQ(decoded, passURL.pass()); 513 } 514 515 static void testUserPass(const String& value, const String& encoded) 516 { 517 testUserPass(value, value, encoded); 518 } 519 520 TEST_F(URLParserTest, Credentials) 521 { 522 auto validSurrogate = utf16String<3>({0xD800, 0xDD55, '\0'}); 523 auto invalidSurrogate = utf16String<3>({0xD800, 'A', '\0'}); 524 auto replacementA = utf16String<3>({0xFFFD, 'A', '\0'}); 525 526 testUserPass("a", "a"); 527 testUserPass("%", "%"); 528 testUserPass("%25", "%", "%25"); 529 testUserPass("%2525", "%25", "%2525"); 530 testUserPass("%FX", "%FX"); 531 testUserPass("%00", String::fromUTF8("\0", 1), "%00"); 532 testUserPass("%F%25", "%F%", "%F%25"); 533 testUserPass("%X%25", "%X%", "%X%25"); 534 testUserPass("%%25", "%%", "%%25"); 535 testUserPass("💩", "%C3%B0%C2%9F%C2%92%C2%A9"); 536 testUserPass("%💩", "%%C3%B0%C2%9F%C2%92%C2%A9"); 537 testUserPass(validSurrogate, "%F0%90%85%95"); 538 testUserPass(replacementA, "%EF%BF%BDA"); 539 testUserPass(invalidSurrogate, replacementA, "%EF%BF%BDA"); 503 540 } 504 541
Note:
See TracChangeset
for help on using the changeset viewer.