Changeset 120433 in webkit
- Timestamp:
- Jun 15, 2012, 2:57:13 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 10 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/files/file-reader-file-url-expected.txt (added)
-
LayoutTests/fast/files/file-reader-file-url.html (added)
-
LayoutTests/fast/files/resources/file-reader-file-url-iframe.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/fileapi/Blob.cpp (modified) (1 diff)
-
Source/WebCore/fileapi/BlobURL.cpp (modified) (2 diffs)
-
Source/WebCore/fileapi/BlobURL.h (modified) (1 diff)
-
Source/WebCore/fileapi/FileReaderLoader.cpp (modified) (1 diff)
-
Source/WebCore/fileapi/ThreadableBlobRegistry.cpp (modified) (5 diffs)
-
Source/WebCore/fileapi/ThreadableBlobRegistry.h (modified) (2 diffs)
-
Source/WebCore/html/DOMURL.cpp (modified) (1 diff)
-
Source/WebCore/page/SecurityOrigin.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r120431 r120433 1 2012-06-15 Jian Li <jianli@chromium.org> 2 3 FileReader is dysfunctional in documents with "null" origin string 4 https://bugs.webkit.org/show_bug.cgi?id=78648 5 6 Reviewed by Adam Barth. 7 8 * fast/files/file-reader-file-url-expected.txt: Added. 9 * fast/files/file-reader-file-url.html: Added. 10 * fast/files/resources/file-reader-file-url-iframe.html: Added. 11 1 12 2012-06-15 Kent Tamura <tkent@chromium.org> 2 13 -
trunk/Source/WebCore/ChangeLog
r120432 r120433 1 2012-06-15 Jian Li <jianli@chromium.org> 2 3 FileReader is dysfunctional in documents with "null" origin string 4 https://bugs.webkit.org/show_bug.cgi?id=78648 5 6 Reviewed by Adam Barth. 7 8 The fix is to keep in-memory map from blob URL to SecurityOrigin for the 9 unique origin case. 10 11 Test: fast/files/file-reader-file-url.html 12 13 * fileapi/Blob.cpp: 14 (WebCore::Blob::Blob): 15 * fileapi/BlobURL.cpp: 16 (WebCore::BlobURL::getOrigin): Return the origin string embeded in the blob URL. 17 (WebCore): 18 (WebCore::BlobURL::createBlobURL): Remove the check for null origin string since it is handled now. 19 * fileapi/BlobURL.h: 20 (BlobURL): 21 * fileapi/FileReaderLoader.cpp: 22 (WebCore::FileReaderLoader::start): 23 * fileapi/ThreadableBlobRegistry.cpp: 24 (WebCore): 25 (WebCore::originMap): Thread-specific in-memory map from the blob URL to the origin. 26 (WebCore::ThreadableBlobRegistry::registerBlobURL): Add the map from the blob URL to the origin. 27 (WebCore::ThreadableBlobRegistry::unregisterBlobURL): Remove the map for the unregistered blob URL. 28 (WebCore::ThreadableBlobRegistry::getCachedOrigin): Retrieve the origin associated with the blob URL. 29 * fileapi/ThreadableBlobRegistry.h: 30 (WebCore): 31 (ThreadableBlobRegistry): 32 * html/DOMURL.cpp: 33 (WebCore::DOMURL::createObjectURL): 34 * page/SecurityOrigin.cpp: 35 (WebCore::getCachedOrigin): Return the cached origin for the blob URL if it exists. 36 (WebCore): 37 (WebCore::SecurityOrigin::create): Call getCachedOrigin to get the cached origin first. 38 1 39 2012-06-15 Yoshifumi Inoue <yosin@chromium.org> 2 40 -
trunk/Source/WebCore/fileapi/Blob.cpp
r120392 r120433 78 78 // Create a new internal URL and register it with the same blob data as the source URL. 79 79 m_internalURL = BlobURL::createInternalURL(); 80 ThreadableBlobRegistry::registerBlobURL( m_internalURL, srcURL);80 ThreadableBlobRegistry::registerBlobURL(0, m_internalURL, srcURL); 81 81 } 82 82 -
trunk/Source/WebCore/fileapi/BlobURL.cpp
r120392 r120433 53 53 } 54 54 55 String BlobURL::getOrigin(const KURL& url) 56 { 57 ASSERT(url.protocolIs(kBlobProtocol)); 58 59 unsigned startIndex = url.pathStart(); 60 unsigned endIndex = url.pathAfterLastSlash(); 61 return url.string().substring(startIndex, endIndex - startIndex - 1); 62 } 63 55 64 String BlobURL::getIdentifier(const KURL& url) 56 65 { … … 64 73 { 65 74 ASSERT(!originString.isEmpty()); 66 if (originString == "null")67 return KURL();68 75 String urlString = kBlobProtocol; 69 76 urlString += ":"; -
trunk/Source/WebCore/fileapi/BlobURL.h
r120392 r120433 51 51 static KURL createPublicURL(SecurityOrigin*); 52 52 static KURL createInternalURL(); 53 static String getOrigin(const KURL&); 53 54 static String getIdentifier(const KURL&); 54 55 static const char* blobProtocol() { return kBlobProtocol; } -
trunk/Source/WebCore/fileapi/FileReaderLoader.cpp
r120392 r120433 81 81 return; 82 82 } 83 ThreadableBlobRegistry::registerBlobURL( m_urlForReading, blob->url());83 ThreadableBlobRegistry::registerBlobURL(scriptExecutionContext->securityOrigin(), m_urlForReading, blob->url()); 84 84 85 85 // Construct and load the request. -
trunk/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp
r120392 r120433 35 35 #include "BlobData.h" 36 36 #include "BlobRegistry.h" 37 #include "BlobURL.h" 38 #include "SecurityOrigin.h" 39 #include <wtf/HashMap.h> 37 40 #include <wtf/MainThread.h> 41 #include <wtf/RefPtr.h> 42 #include <wtf/ThreadSpecific.h> 43 #include <wtf/text/StringHash.h> 44 45 using WTF::ThreadSpecific; 38 46 39 47 namespace WebCore { … … 65 73 #if ENABLE(BLOB) 66 74 75 typedef HashMap<String, RefPtr<SecurityOrigin> > BlobUrlOriginMap; 76 static ThreadSpecific<BlobUrlOriginMap>& originMap() 77 { 78 AtomicallyInitializedStatic(ThreadSpecific<BlobUrlOriginMap>*, map = new ThreadSpecific<BlobUrlOriginMap>); 79 return *map; 80 } 81 67 82 static void registerBlobURLTask(void* context) 68 83 { … … 87 102 } 88 103 89 void ThreadableBlobRegistry::registerBlobURL( const KURL& url, const KURL& srcURL)104 void ThreadableBlobRegistry::registerBlobURL(SecurityOrigin* origin, const KURL& url, const KURL& srcURL) 90 105 { 106 // If the blob URL contains null origin, as in the context with unique security origin or file URL, save the mapping between url and origin so that the origin can be retrived when doing security origin check. 107 if (origin && BlobURL::getOrigin(url) == "null") 108 originMap()->add(url.string(), origin); 109 91 110 if (isMainThread()) 92 111 blobRegistry().registerBlobURL(url, srcURL); … … 105 124 void ThreadableBlobRegistry::unregisterBlobURL(const KURL& url) 106 125 { 107 if (isMainThread()) 126 if (isMainThread()) { 127 originMap()->remove(url.string()); 108 128 blobRegistry().unregisterBlobURL(url); 109 else {129 } else { 110 130 OwnPtr<BlobRegistryContext> context = adoptPtr(new BlobRegistryContext(url)); 111 131 callOnMainThread(&unregisterBlobURLTask, context.leakPtr()); 112 132 } 133 } 134 135 PassRefPtr<SecurityOrigin> ThreadableBlobRegistry::getCachedOrigin(const KURL& url) 136 { 137 return originMap()->get(url.string()); 113 138 } 114 139 … … 126 151 { 127 152 } 153 154 PassRefPtr<SecurityOrigin> ThreadableBlobRegistry::getCachedOrigin(const KURL& url) 155 { 156 return 0; 157 } 158 128 159 #endif // ENABL(BLOB) 129 160 -
trunk/Source/WebCore/fileapi/ThreadableBlobRegistry.h
r120392 r120433 33 33 34 34 #include <wtf/PassOwnPtr.h> 35 #include <wtf/PassRefPtr.h> 35 36 36 37 namespace WebCore { … … 38 39 class BlobData; 39 40 class KURL; 41 class SecurityOrigin; 40 42 41 43 class ThreadableBlobRegistry { 42 44 public: 43 45 static void registerBlobURL(const KURL&, PassOwnPtr<BlobData>); 44 static void registerBlobURL( const KURL&, const KURL& srcURL);46 static void registerBlobURL(SecurityOrigin*, const KURL&, const KURL& srcURL); 45 47 static void unregisterBlobURL(const KURL&); 48 49 // Returns the origin for the given blob URL. This is because we are not able to embed the unique security origin or the origin of file URL 50 // in the blob URL. 51 static PassRefPtr<SecurityOrigin> getCachedOrigin(const KURL&); 46 52 }; 47 53 -
trunk/Source/WebCore/html/DOMURL.cpp
r120392 r120433 79 79 return String(); 80 80 81 ThreadableBlobRegistry::registerBlobURL( publicURL, blob->url());81 ThreadableBlobRegistry::registerBlobURL(scriptExecutionContext->securityOrigin(), publicURL, blob->url()); 82 82 scriptExecutionContext->publicURLManager().blobURLs().add(publicURL.string()); 83 83 -
trunk/Source/WebCore/page/SecurityOrigin.cpp
r120392 r120433 36 36 #include "SchemeRegistry.h" 37 37 #include "SecurityPolicy.h" 38 #include "ThreadableBlobRegistry.h" 38 39 #include <wtf/MainThread.h> 39 40 #include <wtf/StdLibExtras.h> … … 88 89 // we finish implementing it. 89 90 return KURL(ParsedURLString, decodeURLEscapeSequences(url.path())); 91 } 92 93 static PassRefPtr<SecurityOrigin> getCachedOrigin(const KURL& url) 94 { 95 #if ENABLE(BLOB) 96 if (url.protocolIs("blob")) 97 return ThreadableBlobRegistry::getCachedOrigin(url); 98 #endif 99 return 0; 90 100 } 91 101 … … 172 182 PassRefPtr<SecurityOrigin> SecurityOrigin::create(const KURL& url) 173 183 { 184 RefPtr<SecurityOrigin> cachedOrigin = getCachedOrigin(url); 185 if (cachedOrigin.get()) 186 return cachedOrigin; 187 174 188 if (shouldTreatAsUniqueOrigin(url)) { 175 189 RefPtr<SecurityOrigin> origin = adoptRef(new SecurityOrigin());
Note:
See TracChangeset
for help on using the changeset viewer.