Changeset 270526 in webkit
- Timestamp:
- Dec 7, 2020 3:43:43 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r270521 r270526 1 2020-12-07 Alex Christensen <achristensen@webkit.org> 2 3 Parse content after # in data URLs with HLS mime types 4 https://bugs.webkit.org/show_bug.cgi?id=219612 5 <rdar://problem/71039282> 6 7 Reviewed by Darin Adler. 8 9 * fast/url/data-url-mediatype-expected.txt: Added. 10 * fast/url/data-url-mediatype.html: Added. 11 1 12 2020-12-07 Lauro Moura <lmoura@igalia.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r270525 r270526 1 2020-12-07 Alex Christensen <achristensen@webkit.org> 2 3 Parse content after # in data URLs with HLS mime types 4 https://bugs.webkit.org/show_bug.cgi?id=219612 5 <rdar://problem/71039282> 6 7 Reviewed by Darin Adler. 8 9 r267995 made us conform to the behavior of Chrome and Firefox by removing fragments from data URLs before parsing. 10 While this is desirable, there is content in Safari-specific HLS data URLs that needs the content including and after #. 11 So, to fix this, wait until after we know the mime type and remove the fragment if it's not HLS. 12 13 Test: fast/url/data-url-mediatype.html 14 15 * loader/ResourceLoader.cpp: 16 (WebCore::ResourceLoader::loadDataURL): 17 (WebCore::shouldStripFragmentIdentifier): Deleted. 18 * platform/network/DataURLDecoder.cpp: 19 (WebCore::DataURLDecoder::shouldRemoveFragmentIdentifier): 20 (WebCore::DataURLDecoder::DecodeTask::DecodeTask): 21 (WebCore::DataURLDecoder::DecodeTask::process): 22 (WebCore::DataURLDecoder::createDecodeTask): 23 1 24 2020-12-07 Zalan Bujtas <zalan@apple.com> 2 25 -
trunk/Source/WebCore/loader/ResourceLoader.cpp
r267995 r270526 55 55 #include <wtf/Ref.h> 56 56 57 #if PLATFORM(COCOA)58 #include "VersionChecks.h"59 #endif60 61 57 #if ENABLE(CONTENT_EXTENSIONS) 62 58 #include "UserContentController.h" … … 253 249 } 254 250 255 static bool shouldStripFragmentIdentifier()256 {257 #if PLATFORM(COCOA)258 return linkedOnOrAfter(SDKVersion::FirstWithDataURLFragmentRemoval);259 #else260 return true;261 #endif262 }263 264 251 void ResourceLoader::loadDataURL() 265 252 { … … 275 262 if (m_request.requester() == ResourceRequest::Requester::Fetch) 276 263 mode = DataURLDecoder::Mode::ForgivingBase64; 277 if (shouldStripFragmentIdentifier())278 url.removeFragmentIdentifier();279 264 DataURLDecoder::decode(url, scheduleContext, mode, [this, protectedThis = makeRef(*this), url](auto decodeResult) mutable { 280 265 if (this->reachedTerminalState()) -
trunk/Source/WebCore/platform/network/DataURLDecoder.cpp
r267730 r270526 39 39 #include <wtf/text/Base64.h> 40 40 41 #if PLATFORM(COCOA) 42 #include "VersionChecks.h" 43 #endif 44 41 45 namespace WebCore { 42 46 namespace DataURLDecoder { 47 48 static bool shouldRemoveFragmentIdentifier(const String& mediaType) 49 { 50 #if PLATFORM(COCOA) 51 if (!linkedOnOrAfter(SDKVersion::FirstWithDataURLFragmentRemoval)) 52 return false; 53 54 // HLS uses # in the middle of the manifests. 55 return !equalLettersIgnoringASCIICase(mediaType, "video/mpegurl") 56 && !equalLettersIgnoringASCIICase(mediaType, "audio/mpegurl") 57 && !equalLettersIgnoringASCIICase(mediaType, "application/x-mpegurl") 58 && !equalLettersIgnoringASCIICase(mediaType, "vnd.apple.mpegurl"); 59 #else 60 return false; 61 #endif 62 } 43 63 44 64 static WorkQueue& decodeQueue() … … 58 78 WTF_MAKE_FAST_ALLOCATED; 59 79 public: 60 DecodeTask(const String& urlString, const ScheduleContext& scheduleContext, DecodeCompletionHandler&& completionHandler)61 : url String(urlString.isolatedCopy())80 DecodeTask(const URL& url, const ScheduleContext& scheduleContext, DecodeCompletionHandler&& completionHandler) 81 : url(url.isolatedCopy()) 62 82 , scheduleContext(scheduleContext) 63 83 , completionHandler(WTFMove(completionHandler)) … … 72 92 // mediatype := [<mimetype>][;charset=<charsettype>] 73 93 74 if (urlString.find(',') == notFound) 94 const char dataString[] = "data:"; 95 ASSERT(url.string().startsWith(dataString)); 96 97 size_t headerStart = strlen(dataString); 98 size_t headerEnd = url.string().find(',', headerStart); 99 if (headerEnd == notFound) 75 100 return false; 76 77 const char dataString[] = "data:"; 78 ASSERT(urlString.startsWith(dataString)); 79 80 size_t headerStart = strlen(dataString); 81 size_t headerEnd = urlString.find(',', headerStart); 101 if (size_t fragmentInHeader = url.string().reverseFind('#', headerEnd); fragmentInHeader != notFound) 102 return false; 82 103 size_t encodedDataStart = headerEnd == notFound ? headerEnd : headerEnd + 1; 83 104 84 encodedData = StringView(urlString).substring(encodedDataStart); 85 auto header = StringView(urlString).substring(headerStart, headerEnd - headerStart); 105 auto header = StringView(url.string()).substring(headerStart, headerEnd - headerStart); 86 106 87 107 // There might one or two semicolons in the header, find the last one. … … 102 122 mediaType.insert("text/plain", 0); 103 123 124 if (shouldRemoveFragmentIdentifier(mediaType)) 125 url.removeFragmentIdentifier(); 126 127 encodedData = StringView(url.string()).substring(encodedDataStart); 128 104 129 result = parseMediaType(mediaType); 105 130 return true; 106 131 } 107 132 108 const String urlString;133 URL url; 109 134 StringView encodedData; 110 135 bool isBase64 { false }; … … 118 143 { 119 144 return makeUnique<DecodeTask>( 120 url .string(),145 url, 121 146 scheduleContext, 122 147 WTFMove(completionHandler)
Note: See TracChangeset
for help on using the changeset viewer.