Changeset 287039 in webkit
- Timestamp:
- Dec 14, 2021, 12:06:12 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/Source/WebKit/ChangeLog ¶
r287035 r287039 1 2021-12-14 Alex Christensen <achristensen@webkit.org> 2 3 Move FTP disabling from NetworkLoad::start to NetworkDataTask::NetworkDataTask 4 https://bugs.webkit.org/show_bug.cgi?id=234280 5 <rdar://85015428> 6 7 Reviewed by Brady Eidson. 8 9 A NetworkLoad synchronously failing has caused several issues. 10 This issue is when a WKDownload is prevented in this way, we don't have a WKDownload in the UI process yet, 11 and we haven't assigned it an identifier in the network process yet either, so we dereference null and send 12 unreceived messages in many places. To fix this issue, I move the FTP check to the NetworkDataTask constructor 13 like we do with blocked port checks and invalid URL checks. I also found that there is a race condition with 14 CFNetwork also failing to load an empty FTP URL, so we need to prevent us from asking CFNetwork to start a load 15 for which we have scheduled a failure. 16 17 Covered by an API test which used to hit all the horrible failures and now passes reliably. 18 19 * NetworkProcess/NetworkCORSPreflightChecker.cpp: 20 (WebKit::NetworkCORSPreflightChecker::wasBlockedByDisabledFTP): 21 * NetworkProcess/NetworkCORSPreflightChecker.h: 22 * NetworkProcess/NetworkDataTask.cpp: 23 (WebKit::NetworkDataTask::NetworkDataTask): 24 (WebKit::NetworkDataTask::scheduleFailure): 25 * NetworkProcess/NetworkDataTask.h: 26 * NetworkProcess/NetworkLoad.cpp: 27 (WebKit::NetworkLoad::start): 28 (WebKit::NetworkLoad::wasBlockedByDisabledFTP): 29 * NetworkProcess/NetworkLoad.h: 30 * NetworkProcess/PingLoad.cpp: 31 (WebKit::PingLoad::wasBlockedByDisabledFTP): 32 * NetworkProcess/PingLoad.h: 33 * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: 34 (WebKit::NetworkDataTaskCocoa::resume): 35 * Shared/WebErrors.cpp: 36 (WebKit::ftpDisabledError): 37 * Shared/WebErrors.h: 38 1 39 2021-12-14 Tim Horton <timothy_horton@apple.com> 2 40 -
TabularUnified trunk/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.cpp ¶
r287021 r287039 33 33 #include "NetworkProcess.h" 34 34 #include "NetworkResourceLoader.h" 35 #include "WebErrors.h" 35 36 #include <WebCore/CrossOriginAccessControl.h> 36 37 #include <WebCore/SecurityOrigin.h> … … 173 174 } 174 175 176 void NetworkCORSPreflightChecker::wasBlockedByDisabledFTP() 177 { 178 m_completionCallback(ftpDisabledError(m_parameters.originalRequest)); 179 } 180 175 181 NetworkTransactionInformation NetworkCORSPreflightChecker::takeInformation() 176 182 { -
TabularUnified trunk/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.h ¶
r287021 r287039 78 78 void cannotShowURL() final; 79 79 void wasBlockedByRestrictions() final; 80 void wasBlockedByDisabledFTP() final; 80 81 81 82 Parameters m_parameters; -
TabularUnified trunk/Source/WebKit/NetworkProcess/NetworkDataTask.cpp ¶
r284301 r287039 77 77 78 78 if (!requestWithCredentials.url().isValid()) { 79 scheduleFailure( InvalidURLFailure);79 scheduleFailure(FailureType::InvalidURL); 80 80 return; 81 81 } 82 82 83 83 if (!portAllowed(requestWithCredentials.url())) { 84 scheduleFailure(BlockedFailure); 84 scheduleFailure(FailureType::Blocked); 85 return; 86 } 87 88 if (!session.networkProcess().ftpEnabled() 89 && requestWithCredentials.url().protocolIsInFTPFamily()) { 90 scheduleFailure(FailureType::FTPDisabled); 85 91 return; 86 92 } … … 95 101 void NetworkDataTask::scheduleFailure(FailureType type) 96 102 { 103 m_failureScheduled = true; 97 104 RunLoop::main().dispatch([this, weakThis = WeakPtr { *this }, type] { 98 105 if (!weakThis || !m_client) … … 100 107 101 108 switch (type) { 102 case BlockedFailure:109 case FailureType::Blocked: 103 110 m_client->wasBlocked(); 104 111 return; 105 case InvalidURLFailure:112 case FailureType::InvalidURL: 106 113 m_client->cannotShowURL(); 107 114 return; 108 case RestrictedURLFailure:115 case FailureType::RestrictedURL: 109 116 m_client->wasBlockedByRestrictions(); 110 117 return; 118 case FailureType::FTPDisabled: 119 m_client->wasBlockedByDisabledFTP(); 111 120 } 112 121 }); -
TabularUnified trunk/Source/WebKit/NetworkProcess/NetworkDataTask.h ¶
r287021 r287039 70 70 virtual void cannotShowURL() = 0; 71 71 virtual void wasBlockedByRestrictions() = 0; 72 virtual void wasBlockedByDisabledFTP() = 0; 72 73 73 74 virtual bool shouldCaptureExtraNetworkLoadMetrics() const { return false; } … … 146 147 NetworkDataTask(NetworkSession&, NetworkDataTaskClient&, const WebCore::ResourceRequest&, WebCore::StoredCredentialsPolicy, bool shouldClearReferrerOnHTTPSToHTTPRedirect, bool dataTaskIsForMainFrameNavigation); 147 148 148 enum FailureType { 149 BlockedFailure, 150 InvalidURLFailure, 151 RestrictedURLFailure 149 enum class FailureType : uint8_t { 150 Blocked, 151 InvalidURL, 152 RestrictedURL, 153 FTPDisabled 152 154 }; 153 155 void scheduleFailure(FailureType); … … 173 175 String m_suggestedFilename; 174 176 bool m_dataTaskIsForMainFrameNavigation { false }; 177 bool m_failureScheduled { false }; 175 178 }; 176 179 -
TabularUnified trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp ¶
r287021 r287039 68 68 if (!m_task) 69 69 return; 70 71 if (!m_networkProcess->ftpEnabled() && m_parameters.request.url().protocolIsInFTPFamily()) {72 m_task->clearClient();73 m_task = nullptr;74 WebCore::NetworkLoadMetrics emptyMetrics;75 didCompleteWithError(ResourceError { errorDomainWebKitInternal, 0, url(), "FTP URLs are disabled"_s, ResourceError::Type::AccessControl }, emptyMetrics);76 return;77 }78 79 70 m_task->resume(); 80 71 } … … 304 295 } 305 296 297 void NetworkLoad::wasBlockedByDisabledFTP() 298 { 299 m_client.get().didFailLoading(ftpDisabledError(m_currentRequest)); 300 } 301 306 302 void NetworkLoad::didNegotiateModernTLS(const URL& url) 307 303 { -
TabularUnified trunk/Source/WebKit/NetworkProcess/NetworkLoad.h ¶
r287021 r287039 88 88 void cannotShowURL() final; 89 89 void wasBlockedByRestrictions() final; 90 void wasBlockedByDisabledFTP() final; 90 91 void didNegotiateModernTLS(const URL&) final; 91 92 -
TabularUnified trunk/Source/WebKit/NetworkProcess/PingLoad.cpp ¶
r287021 r287039 211 211 } 212 212 213 void PingLoad::wasBlockedByDisabledFTP() 214 { 215 PING_RELEASE_LOG("wasBlockedByDisabledFTP"); 216 didFinish(ftpDisabledError(ResourceRequest(currentURL()))); 217 } 218 213 219 void PingLoad::timeoutTimerFired() 214 220 { -
TabularUnified trunk/Source/WebKit/NetworkProcess/PingLoad.h ¶
r287021 r287039 61 61 void cannotShowURL() final; 62 62 void wasBlockedByRestrictions() final; 63 void wasBlockedByDisabledFTP() final; 63 64 void timeoutTimerFired(); 64 65 -
TabularUnified trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm ¶
r287021 r287039 640 640 WTFEmitSignpost(m_task.get(), "DataTask", "resume"); 641 641 642 if (m_failureScheduled) 643 return; 644 642 645 auto& cocoaSession = static_cast<NetworkSessionCocoa&>(*m_session); 643 646 if (cocoaSession.deviceManagementRestrictionsEnabled() && m_isForMainResourceNavigationForAnyFrame) { … … 645 648 callOnMainRunLoop([this, protectedThis = WTFMove(protectedThis), isBlocked] { 646 649 if (isBlocked) { 647 scheduleFailure( RestrictedURLFailure);650 scheduleFailure(FailureType::RestrictedURL); 648 651 return; 649 652 } -
TabularUnified trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp ¶
r287021 r287039 152 152 153 153 if (!m_currentRequest.url().protocolIsInHTTPFamily()) { 154 scheduleFailure( InvalidURLFailure);154 scheduleFailure(FailureType::InvalidURL); 155 155 return; 156 156 } … … 160 160 m_soupMessage = m_currentRequest.createSoupMessage(m_session->blobRegistry()); 161 161 if (!m_soupMessage) { 162 scheduleFailure( InvalidURLFailure);162 scheduleFailure(FailureType::InvalidURL); 163 163 return; 164 164 } -
TabularUnified trunk/Source/WebKit/Shared/WebErrors.cpp ¶
r264021 r287039 63 63 } 64 64 65 ResourceError ftpDisabledError(const ResourceRequest& request) 66 { 67 return ResourceError(errorDomainWebKitInternal, 0, request.url(), "FTP URLs are disabled"_s, ResourceError::Type::AccessControl); 68 } 69 65 70 ResourceError failedCustomProtocolSyncLoad(const ResourceRequest& request) 66 71 { -
TabularUnified trunk/Source/WebKit/Shared/WebErrors.h ¶
r264021 r287039 42 42 WebCore::ResourceError wasBlockedByRestrictionsError(const WebCore::ResourceRequest&); 43 43 WebCore::ResourceError interruptedForPolicyChangeError(const WebCore::ResourceRequest&); 44 WebCore::ResourceError ftpDisabledError(const WebCore::ResourceRequest&); 44 45 WebCore::ResourceError failedCustomProtocolSyncLoad(const WebCore::ResourceRequest&); 45 46 #if ENABLE(CONTENT_FILTERING) -
TabularUnified trunk/Tools/ChangeLog ¶
r287030 r287039 1 2021-12-14 Alex Christensen <achristensen@webkit.org> 2 3 Move FTP disabling from NetworkLoad::start to NetworkDataTask::NetworkDataTask 4 https://bugs.webkit.org/show_bug.cgi?id=234280 5 6 Reviewed by Brady Eidson. 7 8 * TestWebKitAPI/Tests/WebKitCocoa/Download.mm: 9 1 10 2021-12-11 Dean Jackson <dino@apple.com> 2 11 -
TabularUnified trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm ¶
r285547 r287039 2155 2155 DownloadCallback::DidFailWithError, 2156 2156 }); 2157 2158 failed = false; 2159 [webView startDownloadUsingRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"ftp:///"]] completionHandler:^(WKDownload *download) { 2160 download.delegate = delegate.get(); 2161 delegate.get().didFailWithError = ^(WKDownload *download, NSError *error, NSData *resumeData) { 2162 EXPECT_WK_STREQ(error.domain, WebKitErrorDomain); 2163 EXPECT_EQ(error.code, 101); 2164 failed = true; 2165 }; 2166 }]; 2167 Util::run(&failed); 2168 2169 checkCallbackRecord(delegate.get(), { 2170 DownloadCallback::DidFailWithError, 2171 }); 2157 2172 } 2158 2173
Note:
See TracChangeset
for help on using the changeset viewer.