[prev in list] [next in list] [prev in thread] [next in thread]
List: webkit-changes
Subject: [webkit-changes] [123677] branches/chromium/1180/Source/WebCore
From: kareng () chromium ! org
Date: 2012-07-25 23:39:27
Message-ID: 20120725233927.ABF46777852F () lists ! macosforge ! org
[Download RAW message or body]
[Attachment #2 (text/html)]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[123677] branches/chromium/1180/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: \
verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: \
bold} #msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: \
bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: \
6px; } #logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em \
0; } #logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg \
h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; } \
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; \
} #logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: \
-1.5em; padding-left: 1.5em; } #logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em \
1em 0 1em; background: white;} #logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid \
#fa0; border-bottom: 1px solid #fa0; background: #fff; } #logmsg table th { \
text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted \
#fa0; } #logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: \
0.2em 0.5em; } #logmsg table thead th { text-align: center; border-bottom: 1px solid \
#fa0; } #logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: \
6px; } #patch { width: 100%; }
#patch h4 {font-family: \
verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, \
#patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins \
{background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del \
{background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, \
.info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a \
href="http://trac.webkit.org/projects/webkit/changeset/123677">123677</a></dd> \
<dt>Author</dt> <dd>kareng@chromium.org</dd> <dt>Date</dt> <dd>2012-07-25 16:39:27 \
-0700 (Wed, 25 Jul 2012)</dd> </dl>
<h3>Log Message</h3>
<pre>Merge 123495 - Files from drag and file <input> should use \
getMIMETypeForExtension to determine content type. \
https://bugs.webkit.org/show_bug.cgi?id=91702
Reviewed by Jian Li.
Awhile back, we changed File to only use getWellKnownMIMETypeForExtension to prevent \
web pages from being able to detect what applications a user has installed indirectly \
through the MIME types. However, some sites like YouTube's drag and drop uploader use \
MIME types that aren't in WebKit's internal list, so we relax the restriction for \
Files that originate from an user action.
* fileapi/File.cpp:
(WebCore::getContentTypeFromFileName):
(WebCore::createBlobDataForFile):
(WebCore::createBlobDataForFileWithName):
(WebCore::createBlobDataForFileWithMetadata):
(WebCore::File::createWithRelativePath):
(WebCore::File::File):
* fileapi/File.h:
(File):
(WebCore::File::create):
(WebCore::File::createWithName):
* html/FileInputType.cpp:
(WebCore::FileInputType::createFileList):
* platform/chromium/ChromiumDataObject.cpp:
(WebCore::ChromiumDataObject::addFilename):
* platform/gtk/ClipboardGtk.cpp:
(WebCore::ClipboardGtk::files):
* platform/mac/ClipboardMac.mm:
(WebCore::ClipboardMac::files):
* platform/qt/ClipboardQt.cpp:
(WebCore::ClipboardQt::files):
* platform/win/ClipboardWin.cpp:
(WebCore::ClipboardWin::files):
TBR=dcheng@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10821032</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#brancheschromium1180SourceWebCorefileapiFilecpp">branches/chromium/1180/Source/WebCore/fileapi/File.cpp</a></li>
<li><a href="#brancheschromium1180SourceWebCorefileapiFileh">branches/chromium/1180/Source/WebCore/fileapi/File.h</a></li>
<li><a href="#brancheschromium1180SourceWebCorehtmlFileInputTypecpp">branches/chromium/1180/Source/WebCore/html/FileInputType.cpp</a></li>
<li><a href="#brancheschromium1180SourceWebCoreplatformchromiumChromiumDataObjectcpp" \
>branches/chromium/1180/Source/WebCore/platform/chromium/ChromiumDataObject.cpp</a></li>
>
<li><a href="#brancheschromium1180SourceWebCoreplatformgtkClipboardGtkcpp">branches/chromium/1180/Source/WebCore/platform/gtk/ClipboardGtk.cpp</a></li>
<li><a href="#brancheschromium1180SourceWebCoreplatformmacClipboardMacmm">branches/chromium/1180/Source/WebCore/platform/mac/ClipboardMac.mm</a></li>
<li><a href="#brancheschromium1180SourceWebCoreplatformqtClipboardQtcpp">branches/chromium/1180/Source/WebCore/platform/qt/ClipboardQt.cpp</a></li>
<li><a href="#brancheschromium1180SourceWebCoreplatformwinClipboardWincpp">branches/chromium/1180/Source/WebCore/platform/win/ClipboardWin.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="brancheschromium1180SourceWebCorefileapiFilecpp"></a>
<div class="modfile"><h4>Modified: \
branches/chromium/1180/Source/WebCore/fileapi/File.cpp (123676 => 123677)</h4> <pre \
class="diff"><span> <span class="info">--- \
branches/chromium/1180/Source/WebCore/fileapi/File.cpp 2012-07-25 23:32:58 UTC (rev \
123676)
+++ branches/chromium/1180/Source/WebCore/fileapi/File.cpp 2012-07-25 23:39:27 UTC \
(rev 123677) </span><span class="lines">@@ -34,12 +34,18 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-static String getContentTypeFromFileName(const String& name)
</del><ins>+static String getContentTypeFromFileName(const String& name, \
File::ContentTypeLookupPolicy policy) </ins><span class="cx"> {
</span><span class="cx"> String type;
</span><span class="cx"> int index = name.reverseFind('.');
</span><del>- if (index != -1)
- type = MIMETypeRegistry::getWellKnownMIMETypeForExtension(name.substring(index \
+ 1)); </del><ins>+ if (index != -1) {
+ if (policy == File::WellKnownContentTypes)
+ type = MIMETypeRegistry::getWellKnownMIMETypeForExtension(name.substring(index \
+ 1)); + else {
+ ASSERT(policy == File::AllContentTypes);
+ type = MIMETypeRegistry::getMIMETypeForExtension(name.substring(index + \
1)); + }
+ }
</ins><span class="cx"> return type;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -51,21 +57,21 @@
</span><span class="cx"> return blobData.release();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static PassOwnPtr<BlobData> createBlobDataForFile(const \
String& path) </del><ins>+static PassOwnPtr<BlobData> \
createBlobDataForFile(const String& path, File::ContentTypeLookupPolicy policy) \
</ins><span class="cx"> { </span><del>- return createBlobDataForFileWithType(path, \
getContentTypeFromFileName(path)); </del><ins>+ return \
createBlobDataForFileWithType(path, getContentTypeFromFileName(path, policy)); \
</ins><span class="cx"> } </span><span class="cx">
</span><del>-static PassOwnPtr<BlobData> createBlobDataForFileWithName(const \
String& path, const String& fileSystemName) </del><ins>+static \
PassOwnPtr<BlobData> createBlobDataForFileWithName(const String& path, \
const String& fileSystemName, File::ContentTypeLookupPolicy policy) </ins><span \
class="cx"> { </span><del>- return createBlobDataForFileWithType(path, \
getContentTypeFromFileName(fileSystemName)); </del><ins>+ return \
createBlobDataForFileWithType(path, getContentTypeFromFileName(fileSystemName, \
policy)); </ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(FILE_SYSTEM)
</span><span class="cx"> static PassOwnPtr<BlobData> \
createBlobDataForFileWithMetadata(const String& fileSystemName, const \
FileMetadata& metadata) </span><span class="cx"> {
</span><span class="cx"> OwnPtr<BlobData> blobData = BlobData::create();
</span><del>- blobData->setContentType(getContentTypeFromFileName(fileSystemName));
</del><ins>+ blobData->setContentType(getContentTypeFromFileName(fileSystemName, \
File::WellKnownContentTypes)); </ins><span class="cx"> \
blobData->appendFile(metadata.platformPath, 0, metadata.length, \
metadata.modificationTime); </span><span class="cx"> return blobData.release();
</span><span class="cx"> }
</span><span class="lines">@@ -74,14 +80,14 @@
</span><span class="cx"> #if ENABLE(DIRECTORY_UPLOAD)
</span><span class="cx"> PassRefPtr<File> File::createWithRelativePath(const \
String& path, const String& relativePath) </span><span class="cx"> {
</span><del>- RefPtr<File> file = adoptRef(new File(path));
</del><ins>+ RefPtr<File> file = adoptRef(new File(path, AllContentTypes));
</ins><span class="cx"> file->m_relativePath = relativePath;
</span><span class="cx"> return file.release();
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-File::File(const String& path)
- : Blob(createBlobDataForFile(path), -1)
</del><ins>+File::File(const String& path, ContentTypeLookupPolicy policy)
+ : Blob(createBlobDataForFile(path, policy), -1)
</ins><span class="cx"> , m_path(path)
</span><span class="cx"> , m_name(pathGetFileName(path))
</span><span class="cx"> #if ENABLE(FILE_SYSTEM)
</span><span class="lines">@@ -105,8 +111,8 @@
</span><span class="cx"> // See SerializedScriptValue.cpp for js and v8.
</span><span class="cx"> }
</span><span class="cx">
</span><del>-File::File(const String& path, const String& name)
- : Blob(createBlobDataForFileWithName(path, name), -1)
</del><ins>+File::File(const String& path, const String& name, \
ContentTypeLookupPolicy policy) + : Blob(createBlobDataForFileWithName(path, name, \
policy), -1) </ins><span class="cx"> , m_path(path)
</span><span class="cx"> , m_name(name)
</span><span class="cx"> #if ENABLE(FILE_SYSTEM)
</span></span></pre></div>
<a id="brancheschromium1180SourceWebCorefileapiFileh"></a>
<div class="modfile"><h4>Modified: \
branches/chromium/1180/Source/WebCore/fileapi/File.h (123676 => 123677)</h4> <pre \
class="diff"><span> <span class="info">--- \
branches/chromium/1180/Source/WebCore/fileapi/File.h 2012-07-25 23:32:58 UTC (rev \
123676)
+++ branches/chromium/1180/Source/WebCore/fileapi/File.h 2012-07-25 23:39:27 UTC (rev \
123677) </span><span class="lines">@@ -38,9 +38,16 @@
</span><span class="cx">
</span><span class="cx"> class File : public Blob {
</span><span class="cx"> public:
</span><del>- static PassRefPtr<File> create(const String& path)
</del><ins>+ // AllContentTypes should only be used when the full path/name are \
trusted; otherwise, it could + // allow arbitrary pages to determine what \
applications an user has installed. + enum ContentTypeLookupPolicy {
+ WellKnownContentTypes,
+ AllContentTypes,
+ };
+
+ static PassRefPtr<File> create(const String& path, \
ContentTypeLookupPolicy policy = WellKnownContentTypes) </ins><span class="cx"> {
</span><del>- return adoptRef(new File(path));
</del><ins>+ return adoptRef(new File(path, policy));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // For deserialization.
</span><span class="lines">@@ -64,11 +71,11 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> // 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. </span><del>- static PassRefPtr<File> createWithName(const String& \
path, const String& name) </del><ins>+ static PassRefPtr<File> \
createWithName(const String& path, const String& name, \
ContentTypeLookupPolicy policy = WellKnownContentTypes) </ins><span class="cx"> {
</span><span class="cx"> if (name.isEmpty())
</span><del>- return adoptRef(new File(path));
- return adoptRef(new File(path, name));
</del><ins>+ return adoptRef(new File(path, policy));
+ return adoptRef(new File(path, name, policy));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> virtual unsigned long long size() const;
</span><span class="lines">@@ -89,11 +96,11 @@
</span><span class="cx"> void captureSnapshot(long long& snapshotSize, \
double& snapshotModificationTime) const; </span><span class="cx">
</span><span class="cx"> private:
</span><del>- File(const String& path);
</del><ins>+ File(const String& path, ContentTypeLookupPolicy);
</ins><span class="cx">
</span><span class="cx"> // For deserialization.
</span><span class="cx"> File(const String& path, const KURL& srcURL, \
const String& type); </span><del>- File(const String& path, const \
String& name); </del><ins>+ File(const String& path, const String& \
name, ContentTypeLookupPolicy); </ins><span class="cx">
</span><span class="cx"> # if ENABLE(FILE_SYSTEM)
</span><span class="cx"> File(const String& name, const FileMetadata&);
</span></span></pre></div>
<a id="brancheschromium1180SourceWebCorehtmlFileInputTypecpp"></a>
<div class="modfile"><h4>Modified: \
branches/chromium/1180/Source/WebCore/html/FileInputType.cpp (123676 => 123677)</h4> \
<pre class="diff"><span> <span class="info">--- \
branches/chromium/1180/Source/WebCore/html/FileInputType.cpp 2012-07-25 23:32:58 UTC \
(rev 123676)
+++ branches/chromium/1180/Source/WebCore/html/FileInputType.cpp 2012-07-25 23:39:27 \
UTC (rev 123677) </span><span class="lines">@@ -287,7 +287,7 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> for (size_t i = 0; i < size; i++)
</span><del>- fileList->append(File::createWithName(files[i].path, \
files[i].displayName)); </del><ins>+ \
fileList->append(File::createWithName(files[i].path, files[i].displayName, \
File::AllContentTypes)); </ins><span class="cx"> return fileList;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="brancheschromium1180SourceWebCoreplatformchromiumChromiumDataObjectcpp"></a>
<div class="modfile"><h4>Modified: \
branches/chromium/1180/Source/WebCore/platform/chromium/ChromiumDataObject.cpp \
(123676 => 123677)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/chromium/1180/Source/WebCore/platform/chromium/ChromiumDataObject.cpp 2012-07-25 \
23:32:58 UTC (rev 123676)
+++ branches/chromium/1180/Source/WebCore/platform/chromium/ChromiumDataObject.cpp 2012-07-25 \
23:39:27 UTC (rev 123677) </span><span class="lines">@@ -209,7 +209,7 @@
</span><span class="cx">
</span><span class="cx"> void ChromiumDataObject::addFilename(const String& \
filename, const String& displayName) </span><span class="cx"> {
</span><del>- internalAddFileItem(ChromiumDataObjectItem::createFromFile(File::createWithName(filename, \
displayName))); </del><ins>+ \
internalAddFileItem(ChromiumDataObjectItem::createFromFile(File::createWithName(filename, \
displayName, File::AllContentTypes))); </ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void ChromiumDataObject::addSharedBuffer(const String& \
name, PassRefPtr<SharedBuffer> buffer) </span></span></pre></div>
<a id="brancheschromium1180SourceWebCoreplatformgtkClipboardGtkcpp"></a>
<div class="modfile"><h4>Modified: \
branches/chromium/1180/Source/WebCore/platform/gtk/ClipboardGtk.cpp (123676 => \
123677)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/chromium/1180/Source/WebCore/platform/gtk/ClipboardGtk.cpp 2012-07-25 \
23:32:58 UTC (rev 123676)
+++ branches/chromium/1180/Source/WebCore/platform/gtk/ClipboardGtk.cpp 2012-07-25 \
23:39:27 UTC (rev 123677) </span><span class="lines">@@ -224,7 +224,7 @@
</span><span class="cx"> RefPtr<FileList> fileList = FileList::create();
</span><span class="cx"> const Vector<String>& filenames = \
m_dataObject->filenames(); </span><span class="cx"> for (size_t i = 0; i < \
filenames.size(); i++) </span><del>- \
fileList->append(File::create(filenames[i])); </del><ins>+ \
fileList->append(File::create(filenames[i], File::AllContentTypes)); </ins><span \
class="cx"> return fileList.release(); </span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="brancheschromium1180SourceWebCoreplatformmacClipboardMacmm"></a>
<div class="modfile"><h4>Modified: \
branches/chromium/1180/Source/WebCore/platform/mac/ClipboardMac.mm (123676 => \
123677)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/chromium/1180/Source/WebCore/platform/mac/ClipboardMac.mm 2012-07-25 \
23:32:58 UTC (rev 123676)
+++ branches/chromium/1180/Source/WebCore/platform/mac/ClipboardMac.mm 2012-07-25 \
23:39:27 UTC (rev 123677) </span><span class="lines">@@ -321,7 +321,7 @@
</span><span class="cx"> for (size_t i = 0; i < absoluteURLs.size(); i++) {
</span><span class="cx"> NSURL *absoluteURL = [NSURL \
URLWithString:absoluteURLs[i]]; </span><span class="cx"> ASSERT([absoluteURL \
isFileURL]); </span><del>- fileList->append(File::create([absoluteURL \
path])); </del><ins>+ fileList->append(File::create([absoluteURL path], \
File::AllContentTypes)); </ins><span class="cx"> }
</span><span class="cx"> return fileList.release(); // We will always return a \
FileList, sometimes empty </span><span class="cx"> }
</span></span></pre></div>
<a id="brancheschromium1180SourceWebCoreplatformqtClipboardQtcpp"></a>
<div class="modfile"><h4>Modified: \
branches/chromium/1180/Source/WebCore/platform/qt/ClipboardQt.cpp (123676 => \
123677)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/chromium/1180/Source/WebCore/platform/qt/ClipboardQt.cpp 2012-07-25 23:32:58 \
UTC (rev 123676)
+++ branches/chromium/1180/Source/WebCore/platform/qt/ClipboardQt.cpp 2012-07-25 \
23:39:27 UTC (rev 123677) </span><span class="lines">@@ -207,7 +207,7 @@
</span><span class="cx"> QUrl url = urls[i];
</span><span class="cx"> if (url.scheme() != QLatin1String("file"))
</span><span class="cx"> continue;
</span><del>- fileList->append(File::create(url.toLocalFile()));
</del><ins>+ fileList->append(File::create(url.toLocalFile(), \
File::AllContentTypes)); </ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return fileList.release();
</span></span></pre></div>
<a id="brancheschromium1180SourceWebCoreplatformwinClipboardWincpp"></a>
<div class="modfile"><h4>Modified: \
branches/chromium/1180/Source/WebCore/platform/win/ClipboardWin.cpp (123676 => \
123677)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/chromium/1180/Source/WebCore/platform/win/ClipboardWin.cpp 2012-07-25 \
23:32:58 UTC (rev 123676)
+++ branches/chromium/1180/Source/WebCore/platform/win/ClipboardWin.cpp 2012-07-25 \
23:39:27 UTC (rev 123677) </span><span class="lines">@@ -560,7 +560,7 @@
</span><span class="cx"> for (UINT i = 0; i < fileCount; i++) {
</span><span class="cx"> if (!DragQueryFileW(hdrop, i, filename, \
WTF_ARRAY_LENGTH(filename))) </span><span class="cx"> continue;
</span><del>- \
files->append(File::create(reinterpret_cast<UChar*>(filename))); \
</del><ins>+ \
files->append(File::create(reinterpret_cast<UChar*>(filename), \
File::AllContentTypes)); </ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> GlobalUnlock(medium.hGlobal);
</span></span></pre>
</div>
</div>
</body>
</html>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic