Changeset 93750 in webkit
- Timestamp:
- Aug 24, 2011 5:59:51 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r93749 r93750 1 2011-08-24 Eric Uhrhane <ericu@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 [filesystem/Chromium] Filesystem paths need proper URL escaping 6 https://bugs.webkit.org/show_bug.cgi?id=62811 7 8 Fix http://code.google.com/p/chromium/issues/detail?id=78860 by making 9 KURLChromium.cpp's escaping code actually work. 10 11 Make encodeWithURLEscapeSequences call into googleurl to do proper 12 escaping. Tested in WebKit/chromium/tests/KURLTest.cpp. 13 * platform/KURLGoogle.cpp: 14 (WebCore::encodeWithURLEscapeSequences): 15 1 16 2011-08-24 Chris Palmer <palmer@google.com> 2 17 -
trunk/Source/WebCore/page/SecurityOrigin.cpp
r92068 r93750 66 66 } 67 67 68 69 68 SecurityOrigin::SecurityOrigin(const KURL& url, SandboxFlags sandboxFlags) 70 69 : m_sandboxFlags(sandboxFlags) … … 92 91 #endif 93 92 if (isBlobOrFileSystemProtocol) { 94 KURL originURL(ParsedURLString, url.path());93 KURL originURL(ParsedURLString, decodeURLEscapeSequences(url.path())); 95 94 if (originURL.isValid()) { 96 95 m_protocol = originURL.protocol().lower(); -
trunk/Source/WebCore/platform/KURLGoogle.cpp
r89178 r93750 835 835 } 836 836 837 // This is called to escape a URL string. It is only used externally when838 // constructing mailto: links to set the query section. Since our query setter839 // will automatically do the correct escaping, this function does not have to840 // do any work.841 //842 // There is a possibility that a future caller may use this function in other843 // ways, and may expect to get a valid URL string. The dangerous thing we want844 // to protect against here is accidentally getting '\0' characters in a string845 // that is not supposed to have them. Therefore, we escape these characters.846 837 String encodeWithURLEscapeSequences(const String& notEncodedString) 847 838 { … … 852 843 const char* input = utf8.data(); 853 844 int inputLength = utf8.length(); 854 855 Vector<char, 2048> buffer; 856 for (int i = 0; i < inputLength; i++) { 857 if (!input[i]) 858 buffer.append("%00", 3); 859 else 860 buffer.append(input[i]); 861 } 862 return String(buffer.data(), buffer.size()); 845 url_canon::RawCanonOutputT<char> buffer; 846 if (buffer.length() < inputLength * 3) 847 buffer.Resize(inputLength * 3); 848 849 url_util::EncodeURIComponent(input, inputLength, &buffer); 850 return String(buffer.data(), buffer.length()); 863 851 } 864 852 -
trunk/Source/WebKit/chromium/ChangeLog
r93747 r93750 1 2011-08-24 Eric Uhrhane <ericu@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 [filesystem/Chromium] Filesystem paths need proper URL escaping 6 https://bugs.webkit.org/show_bug.cgi?id=62811 7 8 Fix http://code.google.com/p/chromium/issues/detail?id=78860 by making 9 KURLChromium.cpp's escaping code actually work. 10 11 Here I added the needed calls to encodeWithURLEscapeSequences. 12 * src/AsyncFileSystemChromium.cpp: 13 (WebCore::AsyncFileSystemChromium::virtualPathToFileSystemURL): 14 * src/WorkerAsyncFileSystemChromium.cpp: 15 (WebCore::WorkerAsyncFileSystemChromium::virtualPathToFileSystemURL): 16 17 Here I updated the test to reflect the new functionality in 18 encodeWithURLEscapeSequences. 19 * tests/KURLTest.cpp: 20 1 21 2011-08-24 Ilya Sherman <isherman@chromium.org> 2 22 -
trunk/Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp
r89178 r93750 178 178 KURL url = m_filesystemRootURL; 179 179 // Remove the extra leading slash. 180 url.setPath(url.path() + virtualPath.substring(1));180 url.setPath(url.path() + encodeWithURLEscapeSequences(virtualPath.substring(1))); 181 181 return url; 182 182 } -
trunk/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp
r89178 r93750 228 228 KURL url = m_filesystemRootURL; 229 229 // Remove the extra leading slash. 230 url.setPath(url.path() + virtualPath.substring(1));230 url.setPath(url.path() + encodeWithURLEscapeSequences(virtualPath.substring(1))); 231 231 return url; 232 232 } -
trunk/Source/WebKit/chromium/tests/KURLTest.cpp
r89178 r93750 307 307 TEST(KURLTest, Encode) 308 308 { 309 struct EncodeCase { 310 const char* input; 311 const char* output; 312 } encode_cases[] = { 313 {"hello, world", "hello%2C%20world"}, 314 {"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F", 315 "%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F"}, 316 {"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F", 317 "%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F"}, 318 {" !\"#$%&'()*+,-./", 319 "%20!%22%23%24%25%26'()*%2B%2C-.%2F"}, 320 {"0123456789:;<=>?", 321 "0123456789%3A%3B%3C%3D%3E%3F"}, 322 {"@ABCDEFGHIJKLMNO", 323 "%40ABCDEFGHIJKLMNO"}, 324 {"PQRSTUVWXYZ[\\]^_", 325 "PQRSTUVWXYZ%5B%5C%5D%5E_"}, 326 {"`abcdefghijklmno", 327 "%60abcdefghijklmno"}, 328 {"pqrstuvwxyz{|}~\x7f", 329 "pqrstuvwxyz%7B%7C%7D~%7F"}, 330 }; 331 332 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(encode_cases); i++) { 333 WTF::String input(encode_cases[i].input); 334 WTF::String expectedOutput(encode_cases[i].output); 335 WTF::String output = WebCore::encodeWithURLEscapeSequences(input); 336 EXPECT_EQ(expectedOutput, output); 337 } 338 339 // Our encode escapes NULLs for safety, so we need to check that too. 340 WTF::String input("\x00\x01", 2); 341 WTF::String reference("%00%01"); 342 343 WTF::String output = WebCore::encodeWithURLEscapeSequences(input); 344 EXPECT_EQ(reference, output); 345 309 346 // Also test that it gets converted to UTF-8 properly. 310 347 char16 wideInputHelper[3] = { 0x4f60, 0x597d, 0 }; 311 348 WTF::String wideInput( 312 349 reinterpret_cast<const ::UChar*>(wideInputHelper), 2); 313 WTF::String wideReference(" \xe4\xbd\xa0\xe5\xa5\xbd", 6);350 WTF::String wideReference("%E4%BD%A0%E5%A5%BD"); 314 351 WTF::String wideOutput = 315 352 WebCore::encodeWithURLEscapeSequences(wideInput); 316 353 EXPECT_EQ(wideReference, wideOutput); 317 318 // Our encode only escapes NULLs for safety (see the implementation for319 // more), so we only bother to test a few cases.320 WTF::String input(321 "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", 16);322 WTF::String reference(323 "%00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", 18);324 WTF::String output = WebCore::encodeWithURLEscapeSequences(input);325 EXPECT_EQ(reference, output);326 354 } 327 355
Note: See TracChangeset
for help on using the changeset viewer.