Changeset 149422 in webkit
- Timestamp:
- Apr 30, 2013, 10:16:04 PM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r149417 r149422 1 2013-04-28 Alexey Proskuryakov <ap@apple.com> 2 3 <rdar://problem/13574729> Implement file path restrictions in WebKit Objective C API 4 https://bugs.webkit.org/show_bug.cgi?id=115321 5 6 Reviewed by Darin Adler. 7 8 * UIProcess/API/C/WKPage.cpp: 9 * UIProcess/API/C/WKPage.h: 10 * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::loadFile): 11 * UIProcess/WebPageProxy.h: 12 Added and implemented a C API to load a file while only opening sandbox for 13 a specific directory. 14 15 * UIProcess/API/mac/WKBrowsingContextController.h: Fixed a typo in a comment. 16 17 * UIProcess/API/mac/WKBrowsingContextController.mm: 18 (-[WKBrowsingContextController loadFileURL:restrictToFilesWithin:]): 19 Respect allowedDirectory argument. Updated the function to raise an exception for 20 incorrect input, as decribed in header file. 21 1 22 2013-04-29 Sam Weinig <sam@webkit.org> 2 23 -
trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp
r148420 r149422 93 93 } 94 94 95 void WKPageLoadFile(WKPageRef pageRef, WKURLRef fileURL, WKURLRef resourceDirectoryURL) 96 { 97 toImpl(pageRef)->loadFile(toWTFString(fileURL), toWTFString(resourceDirectoryURL)); 98 } 99 95 100 void WKPageStopLoading(WKPageRef pageRef) 96 101 { -
trunk/Source/WebKit2/UIProcess/API/C/WKPage.h
r148420 r149422 363 363 WK_EXPORT void WKPageLoadPlainTextString(WKPageRef page, WKStringRef plainTextString); 364 364 WK_EXPORT void WKPageLoadWebArchiveData(WKPageRef page, WKDataRef webArchiveData); 365 WK_EXPORT void WKPageLoadFile(WKPageRef page, WKURLRef fileURL, WKURLRef resourceDirectoryURL); 365 366 366 367 WK_EXPORT void WKPageStopLoading(WKPageRef page); -
trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.h
r134681 r149422 51 51 52 52 /* Load a file: URL. Opens the sandbox only for files within allowedDirectory. 53 - Passing a non-file: URL to either parameter will y eild an exception.53 - Passing a non-file: URL to either parameter will yield an exception. 54 54 - Passing nil as the allowedDirectory will open the entire file-system for 55 reading. 55 reading. 56 56 */ 57 57 - (void)loadFileURL:(NSURL *)URL restrictToFilesWithin:(NSURL *)allowedDirectory; -
trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.mm
r149255 r149422 120 120 - (void)loadFileURL:(NSURL *)URL restrictToFilesWithin:(NSURL *)allowedDirectory 121 121 { 122 if (![URL isFileURL]) 123 return; 124 125 /* FIXME: Implement restrictions. */ 122 if (![URL isFileURL] || (allowedDirectory && ![allowedDirectory isFileURL])) 123 [NSException raise:NSInvalidArgumentException format:@"Attempted to load a non-file URL"]; 126 124 127 125 WKRetainPtr<WKURLRef> wkURL = adoptWK(WKURLCreateWithCFURL((CFURLRef)URL)); 128 WKPageLoadURL(self._pageRef, wkURL.get()); 126 WKRetainPtr<WKURLRef> wkAllowedDirectory = adoptWK(WKURLCreateWithCFURL((CFURLRef)allowedDirectory)); 127 128 WKPageLoadFile(self._pageRef, wkURL.get(), wkAllowedDirectory.get()); 129 129 } 130 130 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r149279 r149422 732 732 } 733 733 734 void WebPageProxy::loadFile(const String& fileURLString, const String& resourceDirectoryURLString) 735 { 736 if (!isValid()) 737 reattachToWebProcess(); 738 739 KURL fileURL = KURL(KURL(), fileURLString); 740 if (!fileURL.isLocalFile()) 741 return; 742 743 String resourceDirectoryPath; 744 if (!resourceDirectoryURLString.isNull()) { 745 KURL resourceDirectoryURL = KURL(KURL(), resourceDirectoryURLString); 746 if (!resourceDirectoryURL.isLocalFile()) 747 return; 748 resourceDirectoryPath = resourceDirectoryURL.fileSystemPath(); 749 } else 750 resourceDirectoryPath = ASCIILiteral("/"); 751 752 SandboxExtension::Handle sandboxExtensionHandle; 753 SandboxExtension::createHandle(resourceDirectoryPath, SandboxExtension::ReadOnly, sandboxExtensionHandle); 754 m_process->assumeReadAccessToBaseURL(resourceDirectoryPath); 755 m_process->send(Messages::WebPage::LoadURL(fileURL, sandboxExtensionHandle), m_pageID); 756 m_process->responsivenessTimer()->start(); 757 } 758 734 759 void WebPageProxy::stopLoading() 735 760 { -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r149147 r149422 289 289 void loadPlainTextString(const String& string); 290 290 void loadWebArchiveData(const WebData*); 291 void loadFile(const String& fileURL, const String& resourceDirectoryURL); 291 292 292 293 void stopLoading();
Note:
See TracChangeset
for help on using the changeset viewer.