Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Side by Side Diff: Source/core/page/DragData.cpp

Issue 193803002: Prevent web content from forging File entries in drag and drop. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/page/DragData.h ('k') | Source/web/WebDragData.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. 3 * Copyright (C) 2013 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 62 }
63 63
64 static bool containsHTML(const DataObject* dropData) 64 static bool containsHTML(const DataObject* dropData)
65 { 65 {
66 return dropData->types().contains(mimeTypeTextHTML); 66 return dropData->types().contains(mimeTypeTextHTML);
67 } 67 }
68 68
69 bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const 69 bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
70 { 70 {
71 return m_platformDragData->types().contains(mimeTypeTextURIList) 71 return m_platformDragData->types().contains(mimeTypeTextURIList)
72 || (filenamePolicy == ConvertFilenames && m_platformDragData->containsFi lenames()); 72 || (filenamePolicy == ConvertFilenames
73 && (m_platformDragData->containsFilenames() || !m_platformDragData-> filenameForNavigation().isEmpty()));
kinuko 2014/03/11 13:09:31 nit: feels this condition is a bit hard to read...
73 } 74 }
74 75
75 String DragData::asURL(FilenameConversionPolicy filenamePolicy, String* title) c onst 76 String DragData::asURL(FilenameConversionPolicy filenamePolicy, String* title) c onst
76 { 77 {
77 String url; 78 String url;
78 if (m_platformDragData->types().contains(mimeTypeTextURIList)) 79 if (m_platformDragData->types().contains(mimeTypeTextURIList)) {
79 m_platformDragData->urlAndTitle(url, title); 80 m_platformDragData->urlAndTitle(url, title);
80 else if (filenamePolicy == ConvertFilenames && containsFiles()) 81 } else if (filenamePolicy == ConvertFilenames) {
81 url = filePathToURL(m_platformDragData->filenames()[0]); 82 if (containsFiles())
83 url = filePathToURL(m_platformDragData->filenames()[0]);
84 else
85 url = filePathToURL(m_platformDragData->filenameForNavigation());
86 }
82 return url; 87 return url;
83 } 88 }
84 89
85 bool DragData::containsFiles() const 90 bool DragData::containsFiles() const
86 { 91 {
87 return m_platformDragData->containsFilenames(); 92 return m_platformDragData->containsFilenames();
88 } 93 }
89 94
90 unsigned DragData::numberOfFiles() const 95 unsigned DragData::numberOfFiles() const
91 { 96 {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 168
164 String DragData::droppedFileSystemId() const 169 String DragData::droppedFileSystemId() const
165 { 170 {
166 DraggedIsolatedFileSystem* filesystem = DraggedIsolatedFileSystem::from(m_pl atformDragData); 171 DraggedIsolatedFileSystem* filesystem = DraggedIsolatedFileSystem::from(m_pl atformDragData);
167 if (!filesystem) 172 if (!filesystem)
168 return String(); 173 return String();
169 return filesystem->filesystemId(); 174 return filesystem->filesystemId();
170 } 175 }
171 176
172 } // namespace WebCore 177 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/DragData.h ('k') | Source/web/WebDragData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698