Changeset 220312 in webkit
- Timestamp:
- Aug 5, 2017 12:57:55 AM (7 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r220311 r220312 1 2017-08-05 Brian Burg <bburg@apple.com> 2 3 Web Automation: files selected for upload should be matched against 'accept' attribute values case-insensitively 4 https://bugs.webkit.org/show_bug.cgi?id=175191 5 <rdar://problem/33725790> 6 7 Reviewed by Carlos Garcia Campos. 8 9 Values of the "accept" attribute are to be compared in a case-insensitive manner, per 10 https://html.spec.whatwg.org/multipage/input.html#file-upload-state-(type=file) 11 12 Except for converting MIME types and extensions to lowercase, most of these changes 13 were lost in a rebase prior to landing the patch. 14 15 * UIProcess/Automation/WebAutomationSession.cpp: 16 (WebKit::fileCanBeAcceptedForUpload): Fix some issues: 17 - Handle a file ending in a period. 18 - Handle MIME type inference failing. 19 - Convert extensions and MIMEs to lower case, per specification. 20 21 (WebKit::WebAutomationSession::handleRunOpenPanel): 22 - Strip the leading period from file extensions. 23 - These range converters crash unless the API::Array is retained by a local variable. 24 1 25 2017-08-04 Youenn Fablet <youenn@apple.com> 2 26 -
trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp
r220222 r220312 542 542 return false; 543 543 544 String extension = filename.substring(dotOffset + 1); 544 String extension = filename.substring(dotOffset + 1).convertToASCIILowercase(); 545 if (extension.isEmpty()) 546 return false; 547 545 548 if (allowedFileExtensions.contains(extension)) 546 549 return true; 547 550 548 String mappedMIMEType = WebCore::MIMETypeRegistry::getMIMETypeForExtension(extension); 551 String mappedMIMEType = WebCore::MIMETypeRegistry::getMIMETypeForExtension(extension).convertToASCIILowercase(); 552 if (mappedMIMEType.isEmpty()) 553 return false; 554 549 555 if (allowedMIMETypes.contains(mappedMIMEType)) 550 556 return true; … … 578 584 579 585 HashSet<String> allowedMIMETypes; 580 for (auto type : parameters.acceptMIMETypes()->elementsOfType<API::String>()) 586 auto acceptMIMETypes = parameters.acceptMIMETypes(); 587 for (auto type : acceptMIMETypes->elementsOfType<API::String>()) 581 588 allowedMIMETypes.add(type->string()); 582 589 583 590 HashSet<String> allowedFileExtensions; 584 for (auto type : parameters.acceptFileExtensions()->elementsOfType<API::String>()) 585 allowedFileExtensions.add(type->string()); 591 auto acceptFileExtensions = parameters.acceptFileExtensions(); 592 for (auto type : acceptFileExtensions->elementsOfType<API::String>()) { 593 // WebCore vends extensions with leading periods. Strip these to simplify matching later. 594 String extension = type->string(); 595 ASSERT(extension.characterAt(0) == '.'); 596 allowedFileExtensions.add(extension.substring(1)); 597 } 586 598 587 599 // Per §14.3.10.5 in the W3C spec, if at least one file cannot be accepted, the command should fail.
Note: See TracChangeset
for help on using the changeset viewer.