Changeset 87095 in webkit
- Timestamp:
- May 23, 2011 1:47:06 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r87094 r87095 1 2011-05-23 Adam Klein <adamk@chromium.org> 2 3 Reviewed by Jian Li. 4 5 [fileapi] Add a File::createWithName method to avoid obfuscated filename leakage from FileEntry.file() method 6 https://bugs.webkit.org/show_bug.cgi?id=61155 7 8 Covered by existing tests: fast/filesystem/file-from-file-entry.html 9 fast/filesystem/workers/file-from-file-entry.html 10 fast/filesystem/workers/file-from-file-entry-sync.html 11 12 * fileapi/DOMFileSystem.cpp: 13 (WebCore::DOMFileSystem::createFile): Updated to call createWithName(). 14 * fileapi/DOMFileSystemSync.cpp: 15 (WebCore::DOMFileSystemSync::createFile): Updated to call createWithName(). 16 * fileapi/File.cpp: 17 (WebCore::createBlobDataForFile): Added an optional name argument to fix MIME type lookup. 18 (WebCore::File::createWithRelativePath): Renamed from create() for consistency with new method. 19 (WebCore::File::File): 20 * fileapi/File.h: 21 (WebCore::File::createWithName): 22 * html/FileInputType.cpp: 23 (WebCore::FileInputType::setFileList): Updated the single caller of File::createWithRelativePath(). 24 1 25 2011-05-23 Adrienne Walker <enne@google.com> 2 26 -
trunk/Source/WebCore/fileapi/DOMFileSystem.cpp
r86325 r87095 118 118 class GetPathCallback : public FileSystemCallbacksBase { 119 119 public: 120 static PassOwnPtr<GetPathCallback> create(PassRefPtr<DOMFileSystem> filesystem, const String& path, PassRefPtr<FileCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)120 static PassOwnPtr<GetPathCallback> create(PassRefPtr<DOMFileSystem> filesystem, const String& path, const String& name, PassRefPtr<FileCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) 121 121 { 122 return adoptPtr(new GetPathCallback(filesystem, path, successCallback, errorCallback));122 return adoptPtr(new GetPathCallback(filesystem, path, name, successCallback, errorCallback)); 123 123 } 124 124 … … 128 128 m_path = metadata.platformPath; 129 129 130 m_filesystem->scheduleCallback(m_successCallback.release(), File::create (m_path));130 m_filesystem->scheduleCallback(m_successCallback.release(), File::createWithName(m_path, m_name)); 131 131 } 132 132 133 133 private: 134 GetPathCallback(PassRefPtr<DOMFileSystem> filesystem, const String& path, PassRefPtr<FileCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)134 GetPathCallback(PassRefPtr<DOMFileSystem> filesystem, const String& path, const String& name, PassRefPtr<FileCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) 135 135 : FileSystemCallbacksBase(errorCallback) 136 136 , m_filesystem(filesystem) 137 137 , m_path(path) 138 , m_name(name) 138 139 , m_successCallback(successCallback) 139 140 { … … 142 143 RefPtr<DOMFileSystem> m_filesystem; 143 144 String m_path; 145 String m_name; 144 146 RefPtr<FileCallback> m_successCallback; 145 147 }; … … 151 153 String platformPath = m_asyncFileSystem->virtualToPlatformPath(fileEntry->fullPath()); 152 154 153 m_asyncFileSystem->readMetadata(platformPath, GetPathCallback::create(this, platformPath, successCallback, errorCallback));155 m_asyncFileSystem->readMetadata(platformPath, GetPathCallback::create(this, platformPath, fileEntry->name(), successCallback, errorCallback)); 154 156 } 155 157 -
trunk/Source/WebCore/fileapi/DOMFileSystemSync.cpp
r81599 r87095 170 170 if (!result->m_path.isEmpty()) 171 171 platformPath = result->m_path; 172 return File::create (platformPath);172 return File::createWithName(platformPath, fileEntry->name()); 173 173 } 174 174 -
trunk/Source/WebCore/fileapi/File.cpp
r74380 r87095 34 34 namespace WebCore { 35 35 36 static PassOwnPtr<BlobData> createBlobDataForFile(const String& path )36 static PassOwnPtr<BlobData> createBlobDataForFile(const String& path, const String& name = String()) 37 37 { 38 38 String type; 39 int index = path.reverseFind('.'); 39 const String& nameForMIMEType = !name.isEmpty() ? name : path; 40 int index = nameForMIMEType.reverseFind('.'); 40 41 if (index != -1) 41 type = MIMETypeRegistry::getMIMETypeForExtension( path.substring(index + 1));42 type = MIMETypeRegistry::getMIMETypeForExtension(nameForMIMEType.substring(index + 1)); 42 43 43 44 OwnPtr<BlobData> blobData = BlobData::create(); … … 46 47 return blobData.release(); 47 48 } 49 50 #if ENABLE(DIRECTORY_UPLOAD) 51 PassRefPtr<File> File::createWithRelativePath(const String& path, const String& relativePath) 52 { 53 RefPtr<File> file = adoptRef(new File(path)); 54 file->m_relativePath = relativePath; 55 return file.release(); 56 } 57 #endif 48 58 49 59 File::File(const String& path) … … 61 71 } 62 72 63 #if ENABLE( DIRECTORY_UPLOAD)64 File::File(const String& relativePath, const String& path)65 : Blob(createBlobDataForFile(path ), -1)73 #if ENABLE(FILE_SYSTEM) 74 File::File(const String& path, const String& name) 75 : Blob(createBlobDataForFile(path, name), -1) 66 76 , m_path(path) 67 , m_ relativePath(relativePath)77 , m_name(name) 68 78 { 69 m_name = pathGetFileName(path);70 79 } 71 80 #endif -
trunk/Source/WebCore/fileapi/File.h
r74380 r87095 50 50 51 51 #if ENABLE(DIRECTORY_UPLOAD) 52 static PassRefPtr<File> create(const String& relativePath, const String& path) 52 static PassRefPtr<File> createWithRelativePath(const String& path, const String& relativePath); 53 #endif 54 55 #if ENABLE(FILE_SYSTEM) 56 // Create a file with a name exposed to the author (via File.name and associated DOM properties) that differs from the one provided in the path. 57 static PassRefPtr<File> createWithName(const String& path, const String& name) 53 58 { 54 return adoptRef(new File( relativePath, path));59 return adoptRef(new File(path, name)); 55 60 } 56 61 #endif … … 76 81 private: 77 82 File(const String& path); 78 83 79 84 // For deserialization. 80 85 File(const String& path, const KURL& srcURL, const String& type); 81 86 82 #if ENABLE( DIRECTORY_UPLOAD)83 File(const String& relativePath, const String& path);87 #if ENABLE(FILE_SYSTEM) 88 File(const String& path, const String& name); 84 89 #endif 85 90 -
trunk/Source/WebCore/html/FileInputType.cpp
r74895 r87095 179 179 // Normalize backslashes to slashes before exposing the relative path to script. 180 180 String relativePath = paths[i].substring(1 + rootPath.length()).replace('\\', '/'); 181 m_fileList->append(File::create (relativePath, paths[i]));181 m_fileList->append(File::createWithRelativePath(paths[i], relativePath)); 182 182 } 183 183 return;
Note: See TracChangeset
for help on using the changeset viewer.