Changeset 267730 in webkit
- Timestamp:
- Sep 29, 2020, 12:44:40 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/images/image-data-url-with-spaces-expected.html (added)
-
LayoutTests/fast/images/image-data-url-with-spaces.html (added)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/fetch/data-urls/processing.any-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/fetch/data-urls/processing.any.worker-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/network/DataURLDecoder.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r267724 r267730 1 2020-09-29 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 Data URL image is not rendered if there is whitespace between the mime type and and "base64" string 4 https://bugs.webkit.org/show_bug.cgi?id=216900 5 6 Reviewed by Darin Adler. 7 8 In the new test, 16 cases are included to cover all the permutations of 9 adding spaces before and after the comma and the semicolon. PNG and JPEG 10 formats are used to ensure the mime type is tested. 11 12 * fast/images/image-data-url-with-spaces-expected.html: Added. 13 * fast/images/image-data-url-with-spaces.html: Added. 14 1 15 2020-09-28 Tetsuharu Ohzeki <tetsuharu.ohzeki@gmail.com> 2 16 -
trunk/LayoutTests/imported/w3c/ChangeLog
r267702 r267730 1 2020-09-29 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 Data URL image is not rendered if there is whitespace between the mime type and and "base64" string 4 https://bugs.webkit.org/show_bug.cgi?id=216900 5 6 Reviewed by Darin Adler. 7 8 * web-platform-tests/fetch/data-urls/processing.any-expected.txt: 9 * web-platform-tests/fetch/data-urls/processing.any.worker-expected.txt: 10 1 11 2020-09-28 Chris Dumez <cdumez@apple.com> 2 12 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/data-urls/processing.any-expected.txt
r267651 r267730 53 53 PASS "data:x;base64;x,WA" 54 54 PASS "data:x;base64=x,WA" 55 FAIL "data:; base64,WA" assert_array_equals: lengths differ, expected array [88] length 1, got object "87,65" length 2 56 FAIL "data:; base64,WA" assert_array_equals: lengths differ, expected array [88] length 1, got object "87,65" length 2 57 FAIL "data: ;charset=x ; base64,WA" assert_array_equals: lengths differ, expected array [88] length 1, got object "87,65" length 2 55 PASS "data:; base64,WA" 56 PASS "data:; base64,WA" 57 PASS "data: ;charset=x ; base64,WA" 58 58 PASS "data:;base64;,WA" 59 FAIL "data:;base64 ,WA" assert_array_equals: lengths differ, expected array [88] length 1, got object "87,65" length 2 60 FAIL "data:;base64 ,WA" assert_array_equals: lengths differ, expected array [88] length 1, got object "87,65" length 2 59 PASS "data:;base64 ,WA" 60 PASS "data:;base64 ,WA" 61 61 PASS "data:;base 64,WA" 62 62 PASS "data:;BASe64,WA" -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/data-urls/processing.any.worker-expected.txt
r267651 r267730 53 53 PASS "data:x;base64;x,WA" 54 54 PASS "data:x;base64=x,WA" 55 FAIL "data:; base64,WA" assert_array_equals: lengths differ, expected array [88] length 1, got object "87,65" length 2 56 FAIL "data:; base64,WA" assert_array_equals: lengths differ, expected array [88] length 1, got object "87,65" length 2 57 FAIL "data: ;charset=x ; base64,WA" assert_array_equals: lengths differ, expected array [88] length 1, got object "87,65" length 2 55 PASS "data:; base64,WA" 56 PASS "data:; base64,WA" 57 PASS "data: ;charset=x ; base64,WA" 58 58 PASS "data:;base64;,WA" 59 FAIL "data:;base64 ,WA" assert_array_equals: lengths differ, expected array [88] length 1, got object "87,65" length 2 60 FAIL "data:;base64 ,WA" assert_array_equals: lengths differ, expected array [88] length 1, got object "87,65" length 2 59 PASS "data:;base64 ,WA" 60 PASS "data:;base64 ,WA" 61 61 PASS "data:;base 64,WA" 62 62 PASS "data:;BASe64,WA" -
trunk/Source/WebCore/ChangeLog
r267727 r267730 1 2020-09-29 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 Data URL image is not rendered if there is whitespace between the mime type and and "base64" string 4 https://bugs.webkit.org/show_bug.cgi?id=216900 5 6 Reviewed by Darin Adler. 7 8 According to https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs, 9 spaces are allowed in the data URL to allow better formatting. This 10 means spaces may appear before and after the comma and the semicolon 11 (if it exits in the Data URL). 12 13 Test: fast/images/image-data-url-with-spaces.html 14 15 * platform/network/DataURLDecoder.cpp: 16 (WebCore::DataURLDecoder::DecodeTask::process): 17 1 18 2020-09-28 Yusuke Suzuki <ysuzuki@apple.com> 2 19 -
trunk/Source/WebCore/platform/network/DataURLDecoder.cpp
r264586 r267730 67 67 bool process() 68 68 { 69 // Syntax: 70 // url := data:<header>,<encodedData> 71 // header := [<mediatype>][;base64] 72 // mediatype := [<mimetype>][;charset=<charsettype>] 73 69 74 if (urlString.find(',') == notFound) 70 75 return false; 76 71 77 const char dataString[] = "data:"; 72 const char base64String[] = ";base64";73 74 78 ASSERT(urlString.startsWith(dataString)); 75 79 76 size_t headerEnd = urlString.find(',', strlen(dataString)); 80 size_t headerStart = strlen(dataString); 81 size_t headerEnd = urlString.find(',', headerStart); 77 82 size_t encodedDataStart = headerEnd == notFound ? headerEnd : headerEnd + 1; 78 83 79 84 encodedData = StringView(urlString).substring(encodedDataStart); 80 auto header = StringView(urlString).substring(strlen(dataString), headerEnd - strlen(dataString)); 81 isBase64 = header.endsWithIgnoringASCIICase(StringView(base64String)); 82 auto mediaType = (isBase64 ? header.substring(0, header.length() - strlen(base64String)) : header).toString(); 83 mediaType = mediaType.stripWhiteSpace(); 85 auto header = StringView(urlString).substring(headerStart, headerEnd - headerStart); 86 87 // There might one or two semicolons in the header, find the last one. 88 size_t mediaTypeEnd = header.reverseFind(';'); 89 mediaTypeEnd = mediaTypeEnd == notFound ? header.length() : mediaTypeEnd; 90 91 // formatTypeStart might be at the begining of "base64" or "charset=...". 92 size_t formatTypeStart = mediaTypeEnd + 1; 93 auto formatType = header.substring(formatTypeStart, header.length() - formatTypeStart); 94 formatType = stripLeadingAndTrailingHTTPSpaces(formatType); 95 96 isBase64 = equalLettersIgnoringASCIICase(formatType, "base64"); 97 98 // If header does not end with "base64", mediaType should be the whole header. 99 auto mediaType = (isBase64 ? header.substring(0, mediaTypeEnd) : header).toString(); 100 mediaType = stripLeadingAndTrailingHTTPSpaces(mediaType); 84 101 if (mediaType.startsWith(';')) 85 102 mediaType.insert("text/plain", 0); 103 86 104 result = parseMediaType(mediaType); 87 88 105 return true; 89 106 }
Note:
See TracChangeset
for help on using the changeset viewer.