-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataTransfer's setData, getData, clearData should strip whitespaces on type #2946
Comments
Do you have a test case or demo already? |
I have a very simple test case added in https://bugs.webkit.org/show_bug.cgi?id=175810 |
OK I've run a modified test with live dom viewer: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/5318 In EdgeHTML 15 (via browserstack) I get
|
It seems Edge throws an exception if there's leading whitespace in
|
As confusing as it sounds, iOS WebKit behaves differently from macOS WebKit. On iOS, we always stripped leading & trailing whitespaces. Given that I suspect there could be mobile content out there that depends on this behavior. |
https://bugs.webkit.org/show_bug.cgi?id=175810 Reviewed by Wenson Hsieh. Source/WebCore: Factored out the code to convert MIME type to lowercase after stripping whitespace, and treat "text" as "text/plain" and "url" as "text/uri-list". Specifications: https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransfer-getdata-2 https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransfer-setdata-2 https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransfer-cleardata-2 Stripping of whitespace only happens in WebKit/Blink but it's probably required for compatbility. Spec bug: whatwg/html#2946 Test: editing/pasteboard/datatransfer-getdata-plaintext.html * dom/DataTransfer.cpp: (WebCore::normalizeType): (WebCore::DataTransfer::clearData): (WebCore::DataTransfer::getData const): (WebCore::DataTransfer::setData): * platform/gtk/PasteboardGtk.cpp: (WebCore::selectionDataTypeFromHTMLClipboardType): * platform/ios/PasteboardIOS.mm: (WebCore::cocoaTypeFromHTMLClipboardType): * platform/mac/PasteboardMac.mm: (WebCore::cocoaTypeFromHTMLClipboardType): * platform/win/PasteboardWin.cpp: (WebCore::clipboardTypeFromMIMEType): LayoutTests: Added a regression test. Some test cases were failing on some platforms. * editing/pasteboard/datatransfer-getdata-plaintext-expected.txt: Added. * editing/pasteboard/datatransfer-getdata-plaintext.html: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@221063 268f45cc-cd09-0410-ab3c-d52691b4dbfc
FWIW, stripping whitespace around the MIME type seems reasonable to me. We'll also be doing that for data: URL MIME types. See whatwg/fetch#579. |
Any tests should make sure to test all ASCII whitespace: U+0009, U+000A, U+000C, U+000D, and U+0020. |
it looks some ports of WebKit and Blink strips away whitespaces around the type specified to
DataTranfer
'ssetData
,getData
, andclearData
methods. The comment indicates this was needed for IE compatibility.Since iOS WebKit seems to have always had this behavior, I'm worried that not stripping whitespaces would not be backwards compatible.
Given the options, I think we should change the spec to strip whitespaces around the type name.
It would be great if someone could check the behavior of IE/Edge on Windows as well.
The text was updated successfully, but these errors were encountered: