Changeset 69183 in webkit
- Timestamp:
- Oct 6, 2010 3:59:43 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/CMakeLists.txt
r69178 r69183 1339 1339 platform/network/BlobResourceHandle.cpp 1340 1340 platform/network/Credential.cpp 1341 platform/network/DataURL.cpp 1341 1342 platform/network/FormDataBuilder.cpp 1342 1343 platform/network/FormData.cpp -
trunk/WebCore/ChangeLog
r69181 r69183 1 2010-10-06 Patrick Gansterer <paroga@webkit.org> 2 3 Reviewed by Darin Adler. 4 5 Move parseDataUrl() from CURL into own file 6 https://bugs.webkit.org/show_bug.cgi?id=41462 7 8 Move the data URL parsing algorithm into a new file to use it in ResourceHandleWin too. 9 10 * CMakeLists.txt: 11 * WebCore.gypi: 12 * WebCore.vcproj/WebCore.vcproj: 13 * platform/network/DataURL.cpp: Added. 14 (WebCore::handleDataURL): 15 * platform/network/DataURL.h: Added. 16 * platform/network/curl/ResourceHandleManager.cpp: 17 (WebCore::ResourceHandleManager::dispatchSynchronousJob): 18 (WebCore::ResourceHandleManager::startJob): 19 * platform/network/win/ResourceHandleWin.cpp: 20 (WebCore::ResourceHandle::start): 21 (WebCore::ResourceHandle::fileLoadTimer): 22 1 23 2010-10-06 Dirk Schulze <krit@webkit.org> 2 24 -
trunk/WebCore/WebCore.gypi
r69178 r69183 3007 3007 'platform/network/Credential.h', 3008 3008 'platform/network/DNS.h', 3009 'platform/network/DataURL.cpp', 3010 'platform/network/DataURL.h', 3009 3011 'platform/network/FormData.cpp', 3010 3012 'platform/network/FormData.h', -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r69178 r69183 27427 27427 </File> 27428 27428 <File 27429 RelativePath="..\platform\network\DataURL.cpp" 27430 > 27431 </File> 27432 <File 27433 RelativePath="..\platform\network\DataURL.h" 27434 > 27435 </File> 27436 <File 27429 27437 RelativePath="..\platform\network\FormData.cpp" 27430 27438 > -
trunk/WebCore/platform/network/curl/ResourceHandleManager.cpp
r68679 r69183 35 35 #include "ResourceHandleManager.h" 36 36 37 #include " Base64.h"37 #include "DataURL.h" 38 38 #include "HTTPParsers.h" 39 39 #include "MIMETypeRegistry.h" … … 42 42 #include "ResourceHandle.h" 43 43 #include "ResourceHandleInternal.h" 44 #include "TextEncoding.h"45 44 46 45 #include <errno.h> … … 574 573 } 575 574 576 static void parseDataUrl(ResourceHandle* handle)577 {578 ResourceHandleClient* client = handle->client();579 580 ASSERT(client);581 if (!client)582 return;583 584 String url = handle->firstRequest().url().string();585 ASSERT(url.startsWith("data:", false));586 587 int index = url.find(',');588 if (index == -1) {589 client->cannotShowURL(handle);590 return;591 }592 593 String mediaType = url.substring(5, index - 5);594 String data = url.substring(index + 1);595 596 bool base64 = mediaType.endsWith(";base64", false);597 if (base64)598 mediaType = mediaType.left(mediaType.length() - 7);599 600 if (mediaType.isEmpty())601 mediaType = "text/plain;charset=US-ASCII";602 603 String mimeType = extractMIMETypeFromMediaType(mediaType);604 String charset = extractCharsetFromMediaType(mediaType);605 606 ResourceResponse response;607 response.setMimeType(mimeType);608 609 if (base64) {610 data = decodeURLEscapeSequences(data);611 response.setTextEncodingName(charset);612 client->didReceiveResponse(handle, response);613 614 // WebCore's decoder fails on Acid3 test 97 (whitespace).615 Vector<char> out;616 CString latin1 = data.latin1();617 if (base64Decode(latin1.data(), latin1.length(), out) && out.size() > 0)618 client->didReceiveData(handle, out.data(), out.size(), 0);619 } else {620 // We have to convert to UTF-16 early due to limitations in KURL621 data = decodeURLEscapeSequences(data, TextEncoding(charset));622 response.setTextEncodingName("UTF-16");623 client->didReceiveResponse(handle, response);624 if (data.length() > 0)625 client->didReceiveData(handle, reinterpret_cast<const char*>(data.characters()), data.length() * sizeof(UChar), 0);626 }627 628 client->didFinishLoading(handle, 0);629 }630 631 575 void ResourceHandleManager::dispatchSynchronousJob(ResourceHandle* job) 632 576 { … … 634 578 635 579 if (kurl.protocolIs("data")) { 636 parseDataUrl(job);580 handleDataURL(job); 637 581 return; 638 582 } … … 665 609 666 610 if (kurl.protocolIs("data")) { 667 parseDataUrl(job);611 handleDataURL(job); 668 612 return; 669 613 } -
trunk/WebCore/platform/network/win/ResourceHandleWin.cpp
r68371 r69183 28 28 #include "ResourceHandle.h" 29 29 30 #include "DataURL.h" 30 31 #include "HTTPParsers.h" 31 32 #include "MIMETypeRegistry.h" … … 260 261 bool ResourceHandle::start(NetworkingContext* context) 261 262 { 262 if ( request().url().isLocalFile()) {263 if (firstRequest().url().isLocalFile() || firstRequest().url().protocolIs("data")) { 263 264 ref(); // balanced by deref in fileLoadTimer 264 265 if (d->m_loadSynchronously) … … 349 350 RefPtr<ResourceHandle> protector(this); 350 351 deref(); // balances ref in start 352 353 if (firstRequest().url().protocolIs("data")) { 354 handleDataURL(this); 355 return; 356 } 351 357 352 358 String fileName = firstRequest().url().fileSystemPath();
Note: See TracChangeset
for help on using the changeset viewer.