Changeset 168430 in webkit
- Timestamp:
- May 7, 2014 11:19:21 AM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r168428 r168430 1 2014-05-07 Alexey Proskuryakov <ap@apple.com> 2 3 Eliminate "well known MIME type" support 4 https://bugs.webkit.org/show_bug.cgi?id=132654 5 6 Reviewed by Anders Carlsson. 7 8 Vestiges of FileSystem API. 9 10 * dom/DataTransfer.cpp: 11 (WebCore::DataTransfer::files): 12 (WebCore::DataTransfer::hasFileOfType): 13 * fileapi/File.cpp: 14 (WebCore::File::File): 15 (WebCore::File::contentTypeFromFilePathOrName): 16 * fileapi/File.h: 17 * html/FileInputType.cpp: 18 (WebCore::FileInputType::createFileList): 19 * platform/MIMETypeRegistry.cpp: 20 (WebCore::initializeSupportedImageMIMETypes): 21 (WebCore::findMimeType): Deleted. 22 (WebCore::MIMETypeRegistry::getWellKnownMIMETypeForExtension): Deleted. 23 * platform/MIMETypeRegistry.h: 24 1 25 2014-05-07 Christophe Dumez <ch.dumez@samsung.com> 2 26 -
trunk/Source/WebCore/dom/DataTransfer.cpp
r168333 r168430 180 180 if (newlyCreatedFileList) { 181 181 for (const String& filename : m_pasteboard->readFilenames()) 182 m_fileList->append(File::create(filename , File::AllContentTypes));182 m_fileList->append(File::create(filename)); 183 183 } 184 184 return m_fileList.get(); … … 190 190 191 191 for (const String& filename : m_pasteboard->readFilenames()) { 192 if (equalIgnoringCase(File::contentTypeFromFilePathOrName(filename , File::AllContentTypes), type))192 if (equalIgnoringCase(File::contentTypeFromFilePathOrName(filename), type)) 193 193 return true; 194 194 } -
trunk/Source/WebCore/fileapi/File.cpp
r168333 r168430 38 38 namespace WebCore { 39 39 40 File::File(const String& path , ContentTypeLookupPolicy policy)40 File::File(const String& path) 41 41 : Blob(uninitializedContructor) 42 42 , m_path(path) … … 44 44 { 45 45 m_internalURL = BlobURL::createInternalURL(); 46 m_type = contentTypeFromFilePathOrName(path , policy);46 m_type = contentTypeFromFilePathOrName(path); 47 47 m_size = -1; 48 48 ThreadableBlobRegistry::registerFileBlobURL(m_internalURL, path, m_type); 49 49 } 50 50 51 File::File(const String& path, const String& name , ContentTypeLookupPolicy policy)51 File::File(const String& path, const String& name) 52 52 : Blob(uninitializedContructor) 53 53 , m_path(path) … … 55 55 { 56 56 m_internalURL = BlobURL::createInternalURL(); 57 m_type = contentTypeFromFilePathOrName(name , policy);57 m_type = contentTypeFromFilePathOrName(name); 58 58 m_size = -1; 59 59 ThreadableBlobRegistry::registerFileBlobURL(m_internalURL, path, m_type); … … 88 88 } 89 89 90 String File::contentTypeFromFilePathOrName(const String& name , File::ContentTypeLookupPolicy policy)90 String File::contentTypeFromFilePathOrName(const String& name) 91 91 { 92 92 String type; 93 93 int index = name.reverseFind('.'); 94 94 if (index != -1) { 95 if (policy == File::WellKnownContentTypes) 96 type = MIMETypeRegistry::getWellKnownMIMETypeForExtension(name.substring(index + 1)); 97 else { 98 ASSERT(policy == File::AllContentTypes); 99 type = MIMETypeRegistry::getMIMETypeForExtension(name.substring(index + 1)); 100 } 95 type = MIMETypeRegistry::getMIMETypeForExtension(name.substring(index + 1)); 101 96 } 102 97 return type; -
trunk/Source/WebCore/fileapi/File.h
r168333 r168430 37 37 class File final : public Blob { 38 38 public: 39 // AllContentTypes should only be used when the full path/name are trusted; otherwise, it could 40 // allow arbitrary pages to determine what applications an user has installed. 41 enum ContentTypeLookupPolicy { 42 WellKnownContentTypes, 43 AllContentTypes, 44 }; 45 46 static PassRefPtr<File> create(const String& path, ContentTypeLookupPolicy policy = WellKnownContentTypes) 39 static PassRefPtr<File> create(const String& path) 47 40 { 48 return adoptRef(new File(path , policy));41 return adoptRef(new File(path)); 49 42 } 50 43 … … 55 48 56 49 // 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 , ContentTypeLookupPolicy policy = WellKnownContentTypes)50 static PassRefPtr<File> createWithName(const String& path, const String& name) 58 51 { 59 52 if (name.isEmpty()) 60 return adoptRef(new File(path , policy));61 return adoptRef(new File(path, name , policy));53 return adoptRef(new File(path)); 54 return adoptRef(new File(path, name)); 62 55 } 63 56 … … 71 64 double lastModifiedDate() const; 72 65 73 static String contentTypeFromFilePathOrName(const String& , ContentTypeLookupPolicy);66 static String contentTypeFromFilePathOrName(const String&); 74 67 75 68 private: 76 File(const String& path, ContentTypeLookupPolicy);77 File(const String& path, const String& name , ContentTypeLookupPolicy);69 explicit File(const String& path); 70 File(const String& path, const String& name); 78 71 79 72 File(DeserializationContructor, const String& path, const URL& srcURL, const String& type); -
trunk/Source/WebCore/html/FileInputType.cpp
r167368 r168430 267 267 Vector<RefPtr<File>> fileObjects; 268 268 for (const FileChooserFileInfo& info : files) 269 fileObjects.append(File::createWithName(info.path, info.displayName , File::AllContentTypes));269 fileObjects.append(File::createWithName(info.path, info.displayName)); 270 270 271 271 return FileList::create(std::move(fileObjects)); -
trunk/Source/WebCore/platform/MIMETypeRegistry.cpp
r165676 r168430 144 144 static const char imageJpeg[] = "image/jpeg"; 145 145 static const char octetStream[] = "application/octet-stream"; 146 147 // A table of well known MIME types used when we don't want to leak to the148 // caller information about types known to underlying platform.149 static const TypeExtensionPair wellKnownMimeTypes[] = {150 { textPlain, "txt" },151 { textPlain, "text" },152 { textHtml, "html" },153 { textHtml, "htm" },154 { "text/css", "css" },155 { "text/xml", "xml" },156 { "text/xsl", "xsl" },157 { "image/gif", "gif" },158 { "image/png", "png" },159 { imageJpeg, "jpeg" },160 { imageJpeg, "jpg" },161 { imageJpeg, "jfif" },162 { imageJpeg, "pjpeg" },163 { "image/webp", "webp" },164 { "image/bmp", "bmp" },165 { "application/xhtml+xml", "xhtml" },166 { "application/x-javascript", "js" },167 { "application/json", "json" },168 { octetStream, "exe" },169 { octetStream, "com" },170 { octetStream, "bin" },171 { "application/zip", "zip" },172 { "application/gzip", "gz" },173 { "application/pdf", "pdf" },174 { "application/postscript", "ps" },175 { "image/x-icon", "ico" },176 { "image/tiff", "tiff" },177 { "image/x-xbitmap", "xbm" },178 { "image/svg+xml", "svg" },179 { "application/rss+xml", "rss" },180 { "application/rdf+xml", "rdf" },181 { "application/x-shockwave-flash", "swf" },182 };183 146 184 147 static HashSet<String>* supportedImageResourceMIMETypes; … … 505 468 unsupportedTextMIMETypes = new HashSet<String>; 506 469 initializeUnsupportedTextMIMETypes(); 507 }508 509 static String findMimeType(const TypeExtensionPair* pairs, unsigned numPairs, const String& extension)510 {511 if (!extension.isEmpty()) {512 for (unsigned i = 0; i < numPairs; ++i, ++pairs) {513 if (equalIgnoringCase(extension, pairs->extension))514 return String(pairs->type);515 }516 }517 return String();518 }519 520 String MIMETypeRegistry::getWellKnownMIMETypeForExtension(const String& extension)521 {522 // This method must be thread safe and should not consult the OS/registry.523 String found = findMimeType(wellKnownMimeTypes, sizeof(wellKnownMimeTypes) / sizeof(wellKnownMimeTypes[0]), extension);524 if (!found.isEmpty())525 return found;526 return findMimeType(commonMediaTypes, sizeof(commonMediaTypes) / sizeof(commonMediaTypes[0]), extension);527 470 } 528 471 -
trunk/Source/WebCore/platform/MIMETypeRegistry.h
r165676 r168430 37 37 public: 38 38 static String getMIMETypeForExtension(const String& extension); 39 static String getWellKnownMIMETypeForExtension(const String& extension);40 39 41 40 static Vector<String> getExtensionsForMIMEType(const String& type);
Note: See TracChangeset
for help on using the changeset viewer.