logo

etc_portage

Unnamed repository; edit this file 'description' to name the repository. git clone https://hacktivis.me/git/etc_portage.git

0007-Revert-Remove-support-for-PING-in-HTML-anchors-priva.patch (20979B)


  1. From aa8f18d92cc4b753e1cdfe345b5bb0894bcdc2dc Mon Sep 17 00:00:00 2001
  2. From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
  3. Date: Wed, 13 Mar 2019 11:04:41 +0100
  4. Subject: [PATCH 7/8] Revert "Remove support for PING in HTML anchors
  5. [privacy]"
  6. This reverts commit 84921f7b5e96acf31472acd7752ca77158b4c657.
  7. ---
  8. Source/WebCore/Sources.txt | 1 +
  9. Source/WebCore/html/HTMLAnchorElement.cpp | 16 ++
  10. .../html/parser/XSSAuditorDelegate.cpp | 4 +
  11. Source/WebCore/loader/DocumentLoader.cpp | 6 +
  12. Source/WebCore/loader/PingLoader.cpp | 218 ++++++++++++++++++
  13. Source/WebCore/loader/PingLoader.h | 62 +++++
  14. .../loader/cache/CachedResourceLoader.cpp | 3 +
  15. .../page/csp/ContentSecurityPolicy.cpp | 5 +
  16. Source/WebKit/WebProcess/WebPage/WebPage.cpp | 3 +
  17. 9 files changed, 318 insertions(+)
  18. create mode 100644 Source/WebCore/loader/PingLoader.cpp
  19. create mode 100644 Source/WebCore/loader/PingLoader.h
  20. diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt
  21. index bbee4a0695..704e50c773 100644
  22. --- a/Source/WebCore/Sources.txt
  23. +++ b/Source/WebCore/Sources.txt
  24. @@ -1276,6 +1276,7 @@ loader/NavigationAction.cpp
  25. loader/NavigationScheduler.cpp
  26. loader/NetscapePlugInStreamLoader.cpp
  27. loader/ServerTimingParser.cpp
  28. +loader/PingLoader.cpp
  29. loader/PolicyChecker.cpp
  30. loader/ProgressTracker.cpp
  31. loader/ResourceCryptographicDigest.cpp
  32. diff --git a/Source/WebCore/html/HTMLAnchorElement.cpp b/Source/WebCore/html/HTMLAnchorElement.cpp
  33. index e53302748d..0155fc70a1 100644
  34. --- a/Source/WebCore/html/HTMLAnchorElement.cpp
  35. +++ b/Source/WebCore/html/HTMLAnchorElement.cpp
  36. @@ -39,6 +39,7 @@
  37. #include "HTMLPictureElement.h"
  38. #include "KeyboardEvent.h"
  39. #include "MouseEvent.h"
  40. +#include "PingLoader.h"
  41. #include "PlatformMouseEvent.h"
  42. #include "RenderImage.h"
  43. #include "ResourceRequest.h"
  44. @@ -363,6 +364,19 @@ bool HTMLAnchorElement::isLiveLink() const
  45. return isLink() && treatLinkAsLiveForEventType(m_wasShiftKeyDownOnMouseDown ? MouseEventWithShiftKey : MouseEventWithoutShiftKey);
  46. }
  47. +void HTMLAnchorElement::sendPings(const URL& destinationURL)
  48. +{
  49. + if (!document().frame())
  50. + return;
  51. +
  52. + if (!hasAttributeWithoutSynchronization(pingAttr) || !document().settings().hyperlinkAuditingEnabled())
  53. + return;
  54. +
  55. + SpaceSplitString pingURLs(attributeWithoutSynchronization(pingAttr), false);
  56. + for (unsigned i = 0; i < pingURLs.size(); i++)
  57. + PingLoader::sendPing(*document().frame(), document().completeURL(pingURLs[i]), destinationURL);
  58. +}
  59. +
  60. #if USE(SYSTEM_PREVIEW)
  61. bool HTMLAnchorElement::isSystemPreviewLink() const
  62. {
  63. @@ -428,6 +442,8 @@ void HTMLAnchorElement::handleClick(Event& event)
  64. ShouldSendReferrer shouldSendReferrer = hasRel(Relation::NoReferrer) ? NeverSendReferrer : MaybeSendReferrer;
  65. auto newFrameOpenerPolicy = hasRel(Relation::NoOpener) ? std::make_optional(NewFrameOpenerPolicy::Suppress) : std::nullopt;
  66. frame->loader().urlSelected(completedURL, target(), &event, LockHistory::No, LockBackForwardList::No, shouldSendReferrer, document().shouldOpenExternalURLsPolicyToPropagate(), newFrameOpenerPolicy, downloadAttribute, systemPreviewInfo);
  67. +
  68. + sendPings(completedURL);
  69. }
  70. HTMLAnchorElement::EventType HTMLAnchorElement::eventType(Event& event)
  71. diff --git a/Source/WebCore/html/parser/XSSAuditorDelegate.cpp b/Source/WebCore/html/parser/XSSAuditorDelegate.cpp
  72. index e8c69162aa..80b4213669 100644
  73. --- a/Source/WebCore/html/parser/XSSAuditorDelegate.cpp
  74. +++ b/Source/WebCore/html/parser/XSSAuditorDelegate.cpp
  75. @@ -35,6 +35,7 @@
  76. #include "FrameLoaderClient.h"
  77. #include "HTMLParserIdioms.h"
  78. #include "NavigationScheduler.h"
  79. +#include "PingLoader.h"
  80. #include <wtf/JSONValues.h>
  81. #include <wtf/text/StringBuilder.h>
  82. #include <wtf/text/CString.h>
  83. @@ -103,6 +104,9 @@ void XSSAuditorDelegate::didBlockScript(const XSSInfo& xssInfo)
  84. m_didSendNotifications = true;
  85. frameLoader.client().didDetectXSS(m_document.url(), xssInfo.m_didBlockEntirePage);
  86. +
  87. + if (!m_reportURL.isEmpty())
  88. + PingLoader::sendViolationReport(*m_document.frame(), m_reportURL, generateViolationReport(xssInfo), ViolationReportType::XSSAuditor);
  89. }
  90. if (xssInfo.m_didBlockEntirePage)
  91. diff --git a/Source/WebCore/loader/DocumentLoader.cpp b/Source/WebCore/loader/DocumentLoader.cpp
  92. index 37cf9602b2..b9fc289660 100644
  93. --- a/Source/WebCore/loader/DocumentLoader.cpp
  94. +++ b/Source/WebCore/loader/DocumentLoader.cpp
  95. @@ -65,6 +65,7 @@
  96. #include "MemoryCache.h"
  97. #include "NetworkLoadMetrics.h"
  98. #include "Page.h"
  99. +#include "PingLoader.h"
  100. #include "PlatformStrategies.h"
  101. #include "PolicyChecker.h"
  102. #include "ProgressTracker.h"
  103. @@ -2057,6 +2058,11 @@ void DocumentLoader::addConsoleMessage(MessageSource messageSource, MessageLevel
  104. static_cast<ScriptExecutionContext*>(m_frame->document())->addConsoleMessage(messageSource, messageLevel, message, requestIdentifier);
  105. }
  106. +void DocumentLoader::sendCSPViolationReport(URL&& reportURL, Ref<FormData>&& report)
  107. +{
  108. + PingLoader::sendViolationReport(*m_frame, WTFMove(reportURL), WTFMove(report), ViolationReportType::ContentSecurityPolicy);
  109. +}
  110. +
  111. void DocumentLoader::enqueueSecurityPolicyViolationEvent(SecurityPolicyViolationEvent::Init&& eventInit)
  112. {
  113. m_frame->document()->enqueueSecurityPolicyViolationEvent(WTFMove(eventInit));
  114. diff --git a/Source/WebCore/loader/PingLoader.cpp b/Source/WebCore/loader/PingLoader.cpp
  115. new file mode 100644
  116. index 0000000000..134e5560e6
  117. --- /dev/null
  118. +++ b/Source/WebCore/loader/PingLoader.cpp
  119. @@ -0,0 +1,218 @@
  120. +/*
  121. + * Copyright (C) 2010 Google Inc. All rights reserved.
  122. + * Copyright (C) 2015 Roopesh Chander (roop@roopc.net)
  123. + * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
  124. + *
  125. + * Redistribution and use in source and binary forms, with or without
  126. + * modification, are permitted provided that the following conditions are
  127. + * met:
  128. + *
  129. + * * Redistributions of source code must retain the above copyright
  130. + * notice, this list of conditions and the following disclaimer.
  131. + * * Redistributions in binary form must reproduce the above
  132. + * copyright notice, this list of conditions and the following disclaimer
  133. + * in the documentation and/or other materials provided with the
  134. + * distribution.
  135. + * * Neither the name of Google Inc. nor the names of its
  136. + * contributors may be used to endorse or promote products derived from
  137. + * this software without specific prior written permission.
  138. + *
  139. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  140. + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  141. + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  142. + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  143. + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  144. + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  145. + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  146. + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  147. + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  148. + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  149. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  150. + *
  151. + */
  152. +
  153. +#include "config.h"
  154. +#include "PingLoader.h"
  155. +
  156. +#include "ContentSecurityPolicy.h"
  157. +#include "Document.h"
  158. +#include "Frame.h"
  159. +#include "FrameLoader.h"
  160. +#include "FrameLoaderClient.h"
  161. +#include "InspectorInstrumentation.h"
  162. +#include "LoaderStrategy.h"
  163. +#include "NetworkLoadMetrics.h"
  164. +#include "Page.h"
  165. +#include "PlatformStrategies.h"
  166. +#include "ProgressTracker.h"
  167. +#include "ResourceHandle.h"
  168. +#include "ResourceLoadInfo.h"
  169. +#include "ResourceRequest.h"
  170. +#include "ResourceResponse.h"
  171. +#include "SecurityOrigin.h"
  172. +#include "SecurityPolicy.h"
  173. +#include "UserContentController.h"
  174. +#include <wtf/text/CString.h>
  175. +
  176. +namespace WebCore {
  177. +
  178. +#if !ENABLE(CONTENT_EXTENSIONS)
  179. +
  180. +// Returns true if we should block the load.
  181. +static inline bool processContentExtensionRulesForLoad(const Frame&, ResourceRequest&, ResourceType)
  182. +{
  183. + return false;
  184. +}
  185. +
  186. +#else
  187. +
  188. +// Returns true if we should block the load.
  189. +static bool processContentExtensionRulesForLoad(const Frame& frame, ResourceRequest& request, ResourceType resourceType)
  190. +{
  191. + auto* documentLoader = frame.loader().documentLoader();
  192. + if (!documentLoader)
  193. + return false;
  194. + auto* page = frame.page();
  195. + if (!page)
  196. + return false;
  197. + auto status = page->userContentProvider().processContentExtensionRulesForLoad(request.url(), resourceType, *documentLoader);
  198. + applyBlockedStatusToRequest(status, page, request);
  199. + return status.blockedLoad;
  200. +}
  201. +
  202. +#endif
  203. +
  204. +void PingLoader::loadImage(Frame& frame, const URL& url)
  205. +{
  206. + ASSERT(frame.document());
  207. + auto& document = *frame.document();
  208. +
  209. + if (!document.securityOrigin().canDisplay(url)) {
  210. + FrameLoader::reportLocalLoadFailed(&frame, url);
  211. + return;
  212. + }
  213. +
  214. + ResourceRequest request(url);
  215. + if (processContentExtensionRulesForLoad(frame, request, ResourceType::Image))
  216. + return;
  217. +
  218. + document.contentSecurityPolicy()->upgradeInsecureRequestIfNeeded(request, ContentSecurityPolicy::InsecureRequestType::Load);
  219. +
  220. + request.setHTTPHeaderField(HTTPHeaderName::CacheControl, "max-age=0");
  221. +
  222. + HTTPHeaderMap originalRequestHeader = request.httpHeaderFields();
  223. +
  224. + String referrer = SecurityPolicy::generateReferrerHeader(document.referrerPolicy(), request.url(), frame.loader().outgoingReferrer());
  225. + if (!referrer.isEmpty())
  226. + request.setHTTPReferrer(referrer);
  227. + frame.loader().addExtraFieldsToSubresourceRequest(request);
  228. +
  229. + startPingLoad(frame, request, WTFMove(originalRequestHeader), ShouldFollowRedirects::Yes);
  230. +}
  231. +
  232. +// http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperlink-auditing
  233. +void PingLoader::sendPing(Frame& frame, const URL& pingURL, const URL& destinationURL)
  234. +{
  235. + ASSERT(frame.document());
  236. +
  237. + if (!pingURL.protocolIsInHTTPFamily())
  238. + return;
  239. +
  240. + ResourceRequest request(pingURL);
  241. + if (processContentExtensionRulesForLoad(frame, request, ResourceType::Raw))
  242. + return;
  243. +
  244. + auto& document = *frame.document();
  245. + document.contentSecurityPolicy()->upgradeInsecureRequestIfNeeded(request, ContentSecurityPolicy::InsecureRequestType::Load);
  246. +
  247. + request.setHTTPMethod("POST");
  248. + request.setHTTPContentType("text/ping");
  249. + request.setHTTPBody(FormData::create("PING"));
  250. + request.setHTTPHeaderField(HTTPHeaderName::CacheControl, "max-age=0");
  251. +
  252. + HTTPHeaderMap originalRequestHeader = request.httpHeaderFields();
  253. +
  254. + frame.loader().addExtraFieldsToSubresourceRequest(request);
  255. +
  256. + auto& sourceOrigin = document.securityOrigin();
  257. + FrameLoader::addHTTPOriginIfNeeded(request, sourceOrigin.toString());
  258. + request.setHTTPHeaderField(HTTPHeaderName::PingTo, destinationURL);
  259. + if (!SecurityPolicy::shouldHideReferrer(pingURL, frame.loader().outgoingReferrer())) {
  260. + request.setHTTPHeaderField(HTTPHeaderName::PingFrom, document.url());
  261. + if (!sourceOrigin.isSameSchemeHostPort(SecurityOrigin::create(pingURL).get())) {
  262. + String referrer = SecurityPolicy::generateReferrerHeader(document.referrerPolicy(), pingURL, frame.loader().outgoingReferrer());
  263. + if (!referrer.isEmpty())
  264. + request.setHTTPReferrer(referrer);
  265. + }
  266. + }
  267. +
  268. + startPingLoad(frame, request, WTFMove(originalRequestHeader), ShouldFollowRedirects::Yes);
  269. +}
  270. +
  271. +void PingLoader::sendViolationReport(Frame& frame, const URL& reportURL, Ref<FormData>&& report, ViolationReportType reportType)
  272. +{
  273. + ASSERT(frame.document());
  274. +
  275. + ResourceRequest request(reportURL);
  276. + if (processContentExtensionRulesForLoad(frame, request, ResourceType::Raw))
  277. + return;
  278. +
  279. + auto& document = *frame.document();
  280. + document.contentSecurityPolicy()->upgradeInsecureRequestIfNeeded(request, ContentSecurityPolicy::InsecureRequestType::Load);
  281. +
  282. + request.setHTTPMethod("POST"_s);
  283. + request.setHTTPBody(WTFMove(report));
  284. + switch (reportType) {
  285. + case ViolationReportType::ContentSecurityPolicy:
  286. + request.setHTTPContentType("application/csp-report"_s);
  287. + break;
  288. + case ViolationReportType::XSSAuditor:
  289. + request.setHTTPContentType("application/json"_s);
  290. + break;
  291. + }
  292. +
  293. + bool removeCookies = true;
  294. + if (document.securityOrigin().isSameSchemeHostPort(SecurityOrigin::create(reportURL).get()))
  295. + removeCookies = false;
  296. + if (removeCookies)
  297. + request.setAllowCookies(false);
  298. +
  299. + HTTPHeaderMap originalRequestHeader = request.httpHeaderFields();
  300. +
  301. + frame.loader().addExtraFieldsToSubresourceRequest(request);
  302. +
  303. + String referrer = SecurityPolicy::generateReferrerHeader(document.referrerPolicy(), reportURL, frame.loader().outgoingReferrer());
  304. + if (!referrer.isEmpty())
  305. + request.setHTTPReferrer(referrer);
  306. +
  307. + startPingLoad(frame, request, WTFMove(originalRequestHeader), ShouldFollowRedirects::No);
  308. +}
  309. +
  310. +void PingLoader::startPingLoad(Frame& frame, ResourceRequest& request, HTTPHeaderMap&& originalRequestHeaders, ShouldFollowRedirects shouldFollowRedirects)
  311. +{
  312. + unsigned long identifier = frame.page()->progress().createUniqueIdentifier();
  313. + // FIXME: Why activeDocumentLoader? I would have expected documentLoader().
  314. + // It seems like the PingLoader should be associated with the current
  315. + // Document in the Frame, but the activeDocumentLoader will be associated
  316. + // with the provisional DocumentLoader if there is a provisional
  317. + // DocumentLoader.
  318. + bool shouldUseCredentialStorage = frame.loader().client().shouldUseCredentialStorage(frame.loader().activeDocumentLoader(), identifier);
  319. + FetchOptions options;
  320. + options.credentials = shouldUseCredentialStorage ? FetchOptions::Credentials::Include : FetchOptions::Credentials::Omit;
  321. + options.redirect = shouldFollowRedirects == ShouldFollowRedirects::Yes ? FetchOptions::Redirect::Follow : FetchOptions::Redirect::Error;
  322. +
  323. + // FIXME: Move ping loads to normal subresource loading to get normal inspector request instrumentation hooks.
  324. + InspectorInstrumentation::willSendRequestOfType(&frame, identifier, frame.loader().activeDocumentLoader(), request, InspectorInstrumentation::LoadType::Ping);
  325. +
  326. + platformStrategies()->loaderStrategy()->startPingLoad(frame, request, WTFMove(originalRequestHeaders), options, [protectedFrame = makeRef(frame), identifier] (const ResourceError& error, const ResourceResponse& response) {
  327. + if (!response.isNull())
  328. + InspectorInstrumentation::didReceiveResourceResponse(protectedFrame, identifier, protectedFrame->loader().activeDocumentLoader(), response, nullptr);
  329. + if (error.isNull()) {
  330. + NetworkLoadMetrics emptyMetrics;
  331. + InspectorInstrumentation::didFinishLoading(protectedFrame.ptr(), protectedFrame->loader().activeDocumentLoader(), identifier, emptyMetrics, nullptr);
  332. + } else
  333. + InspectorInstrumentation::didFailLoading(protectedFrame.ptr(), protectedFrame->loader().activeDocumentLoader(), identifier, error);
  334. + });
  335. +}
  336. +
  337. +}
  338. diff --git a/Source/WebCore/loader/PingLoader.h b/Source/WebCore/loader/PingLoader.h
  339. new file mode 100644
  340. index 0000000000..15489dcf04
  341. --- /dev/null
  342. +++ b/Source/WebCore/loader/PingLoader.h
  343. @@ -0,0 +1,62 @@
  344. +/*
  345. + * Copyright (C) 2010 Google Inc. All rights reserved.
  346. + * Copyright (C) 2017 Apple Inc. All rights reserved.
  347. + *
  348. + * Redistribution and use in source and binary forms, with or without
  349. + * modification, are permitted provided that the following conditions are
  350. + * met:
  351. + *
  352. + * * Redistributions of source code must retain the above copyright
  353. + * notice, this list of conditions and the following disclaimer.
  354. + * * Redistributions in binary form must reproduce the above
  355. + * copyright notice, this list of conditions and the following disclaimer
  356. + * in the documentation and/or other materials provided with the
  357. + * distribution.
  358. + * * Neither the name of Google Inc. nor the names of its
  359. + * contributors may be used to endorse or promote products derived from
  360. + * this software without specific prior written permission.
  361. + *
  362. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  363. + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  364. + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  365. + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  366. + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  367. + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  368. + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  369. + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  370. + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  371. + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  372. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  373. + *
  374. + */
  375. +
  376. +#pragma once
  377. +
  378. +#include <wtf/Forward.h>
  379. +#include <wtf/Ref.h>
  380. +
  381. +namespace WebCore {
  382. +
  383. +class FormData;
  384. +class Frame;
  385. +class HTTPHeaderMap;
  386. +class URL;
  387. +class ResourceRequest;
  388. +
  389. +enum class ViolationReportType {
  390. + ContentSecurityPolicy,
  391. + XSSAuditor,
  392. +};
  393. +
  394. +class PingLoader {
  395. +public:
  396. + static void loadImage(Frame&, const URL&);
  397. + static void sendPing(Frame&, const URL& pingURL, const URL& destinationURL);
  398. + WEBCORE_EXPORT static void sendViolationReport(Frame&, const URL& reportURL, Ref<FormData>&& report, ViolationReportType);
  399. +
  400. +private:
  401. + enum class ShouldFollowRedirects { No, Yes };
  402. + static void startPingLoad(Frame&, ResourceRequest&, HTTPHeaderMap&& originalRequestHeaders, ShouldFollowRedirects);
  403. +};
  404. +
  405. +} // namespace WebCore
  406. diff --git a/Source/WebCore/loader/cache/CachedResourceLoader.cpp b/Source/WebCore/loader/cache/CachedResourceLoader.cpp
  407. index 614cfee9b5..9d3d108113 100644
  408. --- a/Source/WebCore/loader/cache/CachedResourceLoader.cpp
  409. +++ b/Source/WebCore/loader/cache/CachedResourceLoader.cpp
  410. @@ -57,6 +57,7 @@
  411. #include "Logging.h"
  412. #include "MemoryCache.h"
  413. #include "Page.h"
  414. +#include "PingLoader.h"
  415. #include "PlatformStrategies.h"
  416. #include "RenderElement.h"
  417. #include "ResourceLoadInfo.h"
  418. @@ -201,6 +202,8 @@ ResourceErrorOr<CachedResourceHandle<CachedImage>> CachedResourceLoader::request
  419. if (Document* document = frame->document())
  420. request.upgradeInsecureRequestIfNeeded(*document);
  421. URL requestURL = request.resourceRequest().url();
  422. + if (requestURL.isValid() && canRequest(CachedResource::Type::ImageResource, requestURL, request, ForPreload::No))
  423. + PingLoader::loadImage(*frame, requestURL);
  424. return CachedResourceHandle<CachedImage> { };
  425. }
  426. }
  427. diff --git a/Source/WebCore/page/csp/ContentSecurityPolicy.cpp b/Source/WebCore/page/csp/ContentSecurityPolicy.cpp
  428. index f1b1b51da1..9b966fa02b 100644
  429. --- a/Source/WebCore/page/csp/ContentSecurityPolicy.cpp
  430. +++ b/Source/WebCore/page/csp/ContentSecurityPolicy.cpp
  431. @@ -45,6 +45,7 @@
  432. #include "JSExecState.h"
  433. #include "JSWindowProxy.h"
  434. #include "ParsingUtilities.h"
  435. +#include "PingLoader.h"
  436. #include "ResourceRequest.h"
  437. #include "RuntimeEnabledFeatures.h"
  438. #include "SchemeRegistry.h"
  439. @@ -758,6 +759,10 @@ void ContentSecurityPolicy::reportViolation(const String& effectiveViolatedDirec
  440. if (m_client) {
  441. for (const auto& url : reportURIs)
  442. m_client->sendCSPViolationReport(URL { m_protectedURL, url }, report.copyRef());
  443. + } else {
  444. + auto& document = downcast<Document>(*m_scriptExecutionContext);
  445. + for (const auto& url : reportURIs)
  446. + PingLoader::sendViolationReport(*document.frame(), URL { m_protectedURL, url }, report.copyRef(), ViolationReportType::ContentSecurityPolicy);
  447. }
  448. }
  449. diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp
  450. index e161de3599..5de12b10cc 100644
  451. --- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp
  452. +++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp
  453. @@ -181,6 +181,7 @@
  454. #include <WebCore/NotImplemented.h>
  455. #include <WebCore/Page.h>
  456. #include <WebCore/PageConfiguration.h>
  457. +#include <WebCore/PingLoader.h>
  458. #include <WebCore/PlatformKeyboardEvent.h>
  459. #include <WebCore/PluginDocument.h>
  460. #include <WebCore/PrintContext.h>
  461. @@ -3358,6 +3359,8 @@ void WebPage::sendCSPViolationReport(uint64_t frameID, const WebCore::URL& repor
  462. auto report = reportData.takeData();
  463. if (!report)
  464. return;
  465. + if (auto* frame = WebProcess::singleton().webFrame(frameID))
  466. + PingLoader::sendViolationReport(*frame->coreFrame(), reportURL, report.releaseNonNull(), ViolationReportType::ContentSecurityPolicy);
  467. }
  468. void WebPage::enqueueSecurityPolicyViolationEvent(uint64_t frameID, SecurityPolicyViolationEvent::Init&& eventInit)
  469. --
  470. 2.19.2