Title: [141905] trunk/Source
Revision
141905
Author
[email protected]
Date
2013-02-05 11:06:26 -0800 (Tue, 05 Feb 2013)

Log Message

Call XSSAuditor's didBlockScript() for the threaded HTML parser
https://bugs.webkit.org/show_bug.cgi?id=108726

Reviewed by Adam Barth.

Source/WebCore:

This patch causes us to call didBlockScript() on the main thread if the CompactHTML token has XSSInfo.
To do so, we:
1. Rename DidBlockScriptRequest to XSSInfo.
2. Add an OwnPtr<XSSInfo> field to CompactHTMLToken.
3. Add an isSafeToSendToAnotherThread() method to String and KURL.

We don't yet populate didBlockScriptRequest on the background thread, but this should just work once we do.

No new tests because no new functionality.

* html/parser/BackgroundHTMLParser.cpp:
(WebCore::BackgroundHTMLParser::pumpTokenizer): Update comment for rename.
* html/parser/CompactHTMLToken.cpp:
(SameSizeAsCompactHTMLToken):
(WebCore::CompactHTMLToken::CompactHTMLToken): Add a copy constructor used by Vector.
(WebCore::CompactHTMLToken::isSafeToSendToAnotherThread): Include new m_xssInfo field in safety check.
(WebCore):
(WebCore::CompactHTMLToken::xssInfo): Added.
(WebCore::CompactHTMLToken::setXSSInfo): Added.
* html/parser/CompactHTMLToken.h: Add an OwnPtr<XSSInfo> field to CompactHTMLToken.
(WebCore):
(CompactHTMLToken):
(WTF): Add VectorTraits necessary for copying Vector fields objects that contain an OwnPtr.
* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::processParsedChunkFromBackgroundParser): Add new didBlockScript() call.
(WebCore::HTMLDocumentParser::pumpTokenizer):
* html/parser/XSSAuditor.cpp: Renaming.
(WebCore::XSSAuditor::filterToken):
* html/parser/XSSAuditor.h: Renaming.
(WebCore):
(XSSAuditor):
* html/parser/XSSAuditorDelegate.cpp:
(WebCore::XSSInfo::isSafeToSendToAnotherThread):
(WebCore):
(WebCore::XSSAuditorDelegate::didBlockScript):
* html/parser/XSSAuditorDelegate.h:
(WebCore::XSSInfo::create):
(XSSInfo):
(WebCore::XSSInfo::XSSInfo):
(XSSAuditorDelegate):
* platform/KURL.cpp:
(WebCore::KURL::isSafeToSendToAnotherThread): Added.
(WebCore):
* platform/KURL.h:
(KURL):
* platform/KURLGoogle.cpp:
(WebCore):
(WebCore::KURLGooglePrivate::isSafeToSendToAnotherThread): Added.
* platform/KURLGooglePrivate.h:
(KURLGooglePrivate):
* platform/KURLWTFURLImpl.h:
(WebCore::KURLWTFURLImpl::isSafeToSendToAnotherThread): Added.

Source/WTF:

This patch adds isSafeToSendToAnotherThread() methods to CString, String, ParsedURL and URLString.
These methods check to ensure there are 0 or 1 references.

* wtf/text/CString.cpp:
(WTF::CString::isSafeToSendToAnotherThread): Added.
(WTF):
* wtf/text/CString.h:
(CString):
* wtf/text/WTFString.cpp:
(WTF::String::isSafeToSendToAnotherThread): Added.
(WTF):
* wtf/text/WTFString.h:
(String):
* wtf/url/api/ParsedURL.h:
(WTF::ParsedURL::isSafeToSendToAnotherThread): Added.
* wtf/url/api/URLString.h:
(WTF::URLString::isSafeToSendToAnotherThread): Added.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (141904 => 141905)


--- trunk/Source/WTF/ChangeLog	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WTF/ChangeLog	2013-02-05 19:06:26 UTC (rev 141905)
@@ -1,3 +1,28 @@
+2013-02-05  Tony Gentilcore  <[email protected]>
+
+        Call XSSAuditor's didBlockScript() for the threaded HTML parser
+        https://bugs.webkit.org/show_bug.cgi?id=108726
+
+        Reviewed by Adam Barth.
+
+        This patch adds isSafeToSendToAnotherThread() methods to CString, String, ParsedURL and URLString.
+        These methods check to ensure there are 0 or 1 references.
+
+        * wtf/text/CString.cpp:
+        (WTF::CString::isSafeToSendToAnotherThread): Added.
+        (WTF):
+        * wtf/text/CString.h:
+        (CString):
+        * wtf/text/WTFString.cpp:
+        (WTF::String::isSafeToSendToAnotherThread): Added.
+        (WTF):
+        * wtf/text/WTFString.h:
+        (String):
+        * wtf/url/api/ParsedURL.h:
+        (WTF::ParsedURL::isSafeToSendToAnotherThread): Added.
+        * wtf/url/api/URLString.h:
+        (WTF::URLString::isSafeToSendToAnotherThread): Added.
+
 2013-02-04  Benjamin Poulain  <[email protected]>
 
         Build fix for AtomicString on iOS

Modified: trunk/Source/WTF/wtf/text/CString.cpp (141904 => 141905)


--- trunk/Source/WTF/wtf/text/CString.cpp	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WTF/wtf/text/CString.cpp	2013-02-05 19:06:26 UTC (rev 141905)
@@ -99,6 +99,11 @@
     memcpy(m_buffer->mutableData(), buffer->data(), length + 1);
 }
 
+bool CString::isSafeToSendToAnotherThread() const
+{
+    return !m_buffer || m_buffer->hasOneRef();
+}
+
 bool operator==(const CString& a, const CString& b)
 {
     if (a.isNull() != b.isNull())

Modified: trunk/Source/WTF/wtf/text/CString.h (141904 => 141905)


--- trunk/Source/WTF/wtf/text/CString.h	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WTF/wtf/text/CString.h	2013-02-05 19:06:26 UTC (rev 141905)
@@ -72,6 +72,7 @@
     }
 
     bool isNull() const { return !m_buffer; }
+    bool isSafeToSendToAnotherThread() const;
 
     CStringBuffer* buffer() const { return m_buffer.get(); }
 

Modified: trunk/Source/WTF/wtf/text/WTFString.cpp (141904 => 141905)


--- trunk/Source/WTF/wtf/text/WTFString.cpp	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WTF/wtf/text/WTFString.cpp	2013-02-05 19:06:26 UTC (rev 141905)
@@ -661,6 +661,17 @@
     return m_impl->isolatedCopy();
 }
 
+bool String::isSafeToSendToAnotherThread() const
+{
+    if (!impl())
+        return true;
+    if (impl()->hasOneRef())
+        return true;
+    if (isEmpty())
+        return true;
+    return false;
+}
+
 void String::split(const String& separator, bool allowEmptyEntries, Vector<String>& result) const
 {
     result.clear();

Modified: trunk/Source/WTF/wtf/text/WTFString.h (141904 => 141905)


--- trunk/Source/WTF/wtf/text/WTFString.h	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WTF/wtf/text/WTFString.h	2013-02-05 19:06:26 UTC (rev 141905)
@@ -394,6 +394,7 @@
     bool percentage(int& percentage) const;
 
     WTF_EXPORT_STRING_API String isolatedCopy() const;
+    bool isSafeToSendToAnotherThread() const;
 
     // Prevent Strings from being implicitly convertable to bool as it will be ambiguous on any platform that
     // allows implicit conversion to another pointer type (e.g., Mac allows implicit conversion to NSString*).

Modified: trunk/Source/WTF/wtf/url/api/ParsedURL.h (141904 => 141905)


--- trunk/Source/WTF/wtf/url/api/ParsedURL.h	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WTF/wtf/url/api/ParsedURL.h	2013-02-05 19:06:26 UTC (rev 141905)
@@ -49,6 +49,7 @@
     WTF_EXPORT_PRIVATE explicit ParsedURL(const ParsedURL& base, const String& relative, URLQueryCharsetConverter*);
 
     WTF_EXPORT_PRIVATE ParsedURL isolatedCopy() const;
+    bool isSafeToSendToAnotherThread() const { return m_spec.isSafeToSendToAnotherThread(); }
 
     bool isValid() const { return !m_spec.string().isNull(); }
 

Modified: trunk/Source/WTF/wtf/url/api/URLString.h (141904 => 141905)


--- trunk/Source/WTF/wtf/url/api/URLString.h	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WTF/wtf/url/api/URLString.h	2013-02-05 19:06:26 UTC (rev 141905)
@@ -39,6 +39,7 @@
     URLString() { }
 
     const String& string() const { return m_string;}
+    bool isSafeToSendToAnotherThread() const { return m_string.isSafeToSendToAnotherThread(); }
 
 #ifndef NDEBUG
     WTF_EXPORT_PRIVATE void print() const;

Modified: trunk/Source/WebCore/ChangeLog (141904 => 141905)


--- trunk/Source/WebCore/ChangeLog	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WebCore/ChangeLog	2013-02-05 19:06:26 UTC (rev 141905)
@@ -1,3 +1,63 @@
+2013-02-05  Tony Gentilcore  <[email protected]>
+
+        Call XSSAuditor's didBlockScript() for the threaded HTML parser
+        https://bugs.webkit.org/show_bug.cgi?id=108726
+
+        Reviewed by Adam Barth.
+
+        This patch causes us to call didBlockScript() on the main thread if the CompactHTML token has XSSInfo.
+        To do so, we:
+        1. Rename DidBlockScriptRequest to XSSInfo.
+        2. Add an OwnPtr<XSSInfo> field to CompactHTMLToken.
+        3. Add an isSafeToSendToAnotherThread() method to String and KURL.
+
+        We don't yet populate didBlockScriptRequest on the background thread, but this should just work once we do.
+
+        No new tests because no new functionality.
+
+        * html/parser/BackgroundHTMLParser.cpp:
+        (WebCore::BackgroundHTMLParser::pumpTokenizer): Update comment for rename.
+        * html/parser/CompactHTMLToken.cpp:
+        (SameSizeAsCompactHTMLToken):
+        (WebCore::CompactHTMLToken::CompactHTMLToken): Add a copy constructor used by Vector.
+        (WebCore::CompactHTMLToken::isSafeToSendToAnotherThread): Include new m_xssInfo field in safety check.
+        (WebCore):
+        (WebCore::CompactHTMLToken::xssInfo): Added.
+        (WebCore::CompactHTMLToken::setXSSInfo): Added.
+        * html/parser/CompactHTMLToken.h: Add an OwnPtr<XSSInfo> field to CompactHTMLToken.
+        (WebCore):
+        (CompactHTMLToken):
+        (WTF): Add VectorTraits necessary for copying Vector fields objects that contain an OwnPtr.
+        * html/parser/HTMLDocumentParser.cpp:
+        (WebCore::HTMLDocumentParser::processParsedChunkFromBackgroundParser): Add new didBlockScript() call.
+        (WebCore::HTMLDocumentParser::pumpTokenizer):
+        * html/parser/XSSAuditor.cpp: Renaming.
+        (WebCore::XSSAuditor::filterToken):
+        * html/parser/XSSAuditor.h: Renaming.
+        (WebCore):
+        (XSSAuditor):
+        * html/parser/XSSAuditorDelegate.cpp:
+        (WebCore::XSSInfo::isSafeToSendToAnotherThread):
+        (WebCore):
+        (WebCore::XSSAuditorDelegate::didBlockScript):
+        * html/parser/XSSAuditorDelegate.h:
+        (WebCore::XSSInfo::create):
+        (XSSInfo):
+        (WebCore::XSSInfo::XSSInfo):
+        (XSSAuditorDelegate):
+        * platform/KURL.cpp:
+        (WebCore::KURL::isSafeToSendToAnotherThread): Added.
+        (WebCore):
+        * platform/KURL.h:
+        (KURL):
+        * platform/KURLGoogle.cpp:
+        (WebCore):
+        (WebCore::KURLGooglePrivate::isSafeToSendToAnotherThread): Added.
+        * platform/KURLGooglePrivate.h:
+        (KURLGooglePrivate):
+        * platform/KURLWTFURLImpl.h:
+        (WebCore::KURLWTFURLImpl::isSafeToSendToAnotherThread): Added.
+
 2013-02-05  Anton Vayvod  <[email protected]>
 
         TextAutosizing: adjust the maximum difference between cluster text width and its descendant

Modified: trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp (141904 => 141905)


--- trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp	2013-02-05 19:06:26 UTC (rev 141905)
@@ -153,7 +153,7 @@
 void BackgroundHTMLParser::pumpTokenizer()
 {
     while (m_tokenizer->nextToken(m_input.current(), *m_token.get())) {
-        // FIXME: Call m_xssAuditor.filterToken(m_token) and put resulting DidBlockScriptRequest into CompactHTMLToken.
+        // FIXME: Call m_xssAuditor.filterToken(m_token) and put resulting XSSInfo into CompactHTMLToken.
         m_pendingTokens->append(CompactHTMLToken(m_token.get(), TextPosition(m_input.current().currentLine(), m_input.current().currentColumn())));
         m_token->clear();
 

Modified: trunk/Source/WebCore/html/parser/CompactHTMLToken.cpp (141904 => 141905)


--- trunk/Source/WebCore/html/parser/CompactHTMLToken.cpp	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WebCore/html/parser/CompactHTMLToken.cpp	2013-02-05 19:06:26 UTC (rev 141905)
@@ -30,6 +30,7 @@
 #include "CompactHTMLToken.h"
 
 #include "HTMLToken.h"
+#include "XSSAuditorDelegate.h"
 
 namespace WebCore {
 
@@ -38,6 +39,7 @@
     String name;
     Vector<CompactAttribute> vector;
     TextPosition textPosition;
+    OwnPtr<XSSInfo> xssInfo;
 };
 
 COMPILE_ASSERT(sizeof(CompactHTMLToken) == sizeof(SameSizeAsCompactHTMLToken), CompactHTMLToken_should_stay_small);
@@ -86,29 +88,39 @@
     }
 }
 
-static bool isStringSafeToSendToAnotherThread(const String& string)
+CompactHTMLToken::CompactHTMLToken(const CompactHTMLToken& other)
+    : m_type(other.type())
+    , m_isAll8BitData(other.isAll8BitData())
+    , m_doctypeForcesQuirks(other.doctypeForcesQuirks())
+    , m_textPosition(other.textPosition())
 {
-    StringImpl* impl = string.impl();
-    if (!impl)
-        return true;
-    if (impl->hasOneRef())
-        return true;
-    if (string.isEmpty())
-        return true;
-    return false;
+    if (other.xssInfo())
+        m_xssInfo = adoptPtr(new XSSInfo(*other.xssInfo()));
 }
 
 bool CompactHTMLToken::isSafeToSendToAnotherThread() const
 {
     for (Vector<CompactAttribute>::const_iterator it = m_attributes.begin(); it != m_attributes.end(); ++it) {
-        if (!isStringSafeToSendToAnotherThread(it->name()))
+        if (!it->name().isSafeToSendToAnotherThread())
             return false;
-        if (!isStringSafeToSendToAnotherThread(it->value()))
+        if (!it->value().isSafeToSendToAnotherThread())
             return false;
     }
-    return isStringSafeToSendToAnotherThread(m_data);
+    if (m_xssInfo && !m_xssInfo->isSafeToSendToAnotherThread())
+        return false;
+    return m_data.isSafeToSendToAnotherThread();
 }
 
+XSSInfo* CompactHTMLToken::xssInfo() const
+{
+    return m_xssInfo.get();
 }
 
+void CompactHTMLToken::setXSSInfo(PassOwnPtr<XSSInfo> xssInfo)
+{
+    m_xssInfo = xssInfo;
+}
+
+}
+
 #endif // ENABLE(THREADED_HTML_PARSER)

Modified: trunk/Source/WebCore/html/parser/CompactHTMLToken.h (141904 => 141905)


--- trunk/Source/WebCore/html/parser/CompactHTMLToken.h	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WebCore/html/parser/CompactHTMLToken.h	2013-02-05 19:06:26 UTC (rev 141905)
@@ -29,6 +29,8 @@
 #if ENABLE(THREADED_HTML_PARSER)
 
 #include "HTMLTokenTypes.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
@@ -38,6 +40,7 @@
 namespace WebCore {
 
 class HTMLToken;
+class XSSInfo;
 
 class CompactAttribute {
 public:
@@ -58,6 +61,7 @@
 class CompactHTMLToken {
 public:
     CompactHTMLToken(const HTMLToken*, const TextPosition&);
+    CompactHTMLToken(const CompactHTMLToken&);
 
     bool isSafeToSendToAnotherThread() const;
 
@@ -73,6 +77,8 @@
     const String& publicIdentifier() const { return m_attributes[0].name(); }
     const String& systemIdentifier() const { return m_attributes[0].value(); }
     bool doctypeForcesQuirks() const { return m_doctypeForcesQuirks; }
+    XSSInfo* xssInfo() const;
+    void setXSSInfo(PassOwnPtr<XSSInfo>);
 
 private:
     unsigned m_type : 4;
@@ -83,12 +89,19 @@
     String m_data; // "name", "characters", or "data" depending on m_type
     Vector<CompactAttribute> m_attributes;
     TextPosition m_textPosition;
+    OwnPtr<XSSInfo> m_xssInfo;
 };
 
 typedef Vector<CompactHTMLToken> CompactHTMLTokenStream;
 
 }
 
+namespace WTF {
+// This is required for a struct with OwnPtr. We know CompactHTMLToken is simple enough that
+// initializing to 0 and moving with memcpy (and then not destructing the original) will work.
+template<> struct VectorTraits<WebCore::CompactHTMLToken> : SimpleClassVectorTraits { };
+}
+
 #endif // ENABLE(THREADED_HTML_PARSER)
 
 #endif

Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp (141904 => 141905)


--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp	2013-02-05 19:06:26 UTC (rev 141905)
@@ -302,7 +302,7 @@
 {
     ASSERT(shouldUseThreading());
 
-    // didReceiveTokensFromBackgroundParser can cause this parser to be detached from the Document,
+    // This method can cause this parser to be detached from the Document,
     // but we need to ensure it isn't deleted yet.
     RefPtr<HTMLDocumentParser> protect(this);
 
@@ -316,8 +316,10 @@
     for (Vector<CompactHTMLToken>::const_iterator it = tokens->begin(); it != tokens->end(); ++it) {
         ASSERT(!isWaitingForScripts());
 
-        // FIXME: Call m_xssAuditorDelegate.didBlockScript() with DidBlockScriptRequest from the CompactHTMLToken.
         m_textPosition = it->textPosition();
+
+        if (XSSInfo* xssInfo = it->xssInfo())
+            m_xssAuditorDelegate.didBlockScript(*xssInfo);
         constructTreeFromCompactHTMLToken(*it);
 
         if (isStopped())
@@ -378,9 +380,9 @@
 
             // We do not XSS filter innerHTML, which means we (intentionally) fail
             // http/tests/security/xssAuditor/dom-write-innerHTML.html
-            OwnPtr<DidBlockScriptRequest> request = m_xssAuditor.filterToken(FilterTokenRequest(token(), m_sourceTracker, document()->decoder()));
-            if (request)
-                m_xssAuditorDelegate.didBlockScript(request.release());
+            OwnPtr<XSSInfo> xssInfo = m_xssAuditor.filterToken(FilterTokenRequest(token(), m_sourceTracker, document()->decoder()));
+            if (xssInfo)
+                m_xssAuditorDelegate.didBlockScript(*xssInfo);
         }
 
         constructTreeFromHTMLToken(token());

Modified: trunk/Source/WebCore/html/parser/XSSAuditor.cpp (141904 => 141905)


--- trunk/Source/WebCore/html/parser/XSSAuditor.cpp	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WebCore/html/parser/XSSAuditor.cpp	2013-02-05 19:06:26 UTC (rev 141905)
@@ -278,7 +278,7 @@
     }
 }
 
-PassOwnPtr<DidBlockScriptRequest> XSSAuditor::filterToken(const FilterTokenRequest& request)
+PassOwnPtr<XSSInfo> XSSAuditor::filterToken(const FilterTokenRequest& request)
 {
     ASSERT(m_state == Initialized);
     if (!m_isEnabled || m_xssProtection == XSSProtectionDisabled)
@@ -296,13 +296,13 @@
 
     if (didBlockScript) {
         bool didBlockEntirePage = (m_xssProtection == XSSProtectionBlockEnabled);
-        OwnPtr<DidBlockScriptRequest> didBlockScriptRequest = DidBlockScriptRequest::create(m_reportURL, m_originalURL, m_originalHTTPBody, didBlockEntirePage);
+        OwnPtr<XSSInfo> xssInfo = XSSInfo::create(m_reportURL, m_originalURL, m_originalHTTPBody, didBlockEntirePage);
         if (!m_reportURL.isEmpty()) {
             m_reportURL = KURL();
             m_originalURL = String();
             m_originalHTTPBody = String();
         }
-        return didBlockScriptRequest.release();
+        return xssInfo.release();
     }
     return nullptr;
 }

Modified: trunk/Source/WebCore/html/parser/XSSAuditor.h (141904 => 141905)


--- trunk/Source/WebCore/html/parser/XSSAuditor.h	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WebCore/html/parser/XSSAuditor.h	2013-02-05 19:06:26 UTC (rev 141905)
@@ -33,11 +33,11 @@
 
 namespace WebCore {
 
-class DidBlockScriptRequest;
 class Document;
 class HTMLDocumentParser;
 class HTMLSourceTracker;
 class TextResourceDecoder;
+class XSSInfo;
 
 struct FilterTokenRequest {
     FilterTokenRequest(HTMLToken& token, HTMLSourceTracker& sourceTracker, const TextResourceDecoder* decoder)
@@ -57,7 +57,7 @@
     explicit XSSAuditor(HTMLDocumentParser*);
 
     void init(Document*);
-    PassOwnPtr<DidBlockScriptRequest> filterToken(const FilterTokenRequest&);
+    PassOwnPtr<XSSInfo> filterToken(const FilterTokenRequest&);
 
 private:
     static const size_t kMaximumFragmentLengthTarget = 100;

Modified: trunk/Source/WebCore/html/parser/XSSAuditorDelegate.cpp (141904 => 141905)


--- trunk/Source/WebCore/html/parser/XSSAuditorDelegate.cpp	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WebCore/html/parser/XSSAuditorDelegate.cpp	2013-02-05 19:06:26 UTC (rev 141905)
@@ -32,12 +32,20 @@
 #include "FormData.h"
 #include "Frame.h"
 #include "FrameLoaderClient.h"
+#include "HTMLParserIdioms.h"
 #include "InspectorValues.h"
 #include "PingLoader.h"
 #include "SecurityOrigin.h"
 
 namespace WebCore {
 
+bool XSSInfo::isSafeToSendToAnotherThread() const
+{
+    return m_reportURL.isSafeToSendToAnotherThread()
+        && m_originalURL.isSafeToSendToAnotherThread()
+        && m_originalHTTPBody.isSafeToSendToAnotherThread();
+}
+
 XSSAuditorDelegate::XSSAuditorDelegate(Document* document)
     : m_document(document)
     , m_didNotifyClient(false)
@@ -46,7 +54,7 @@
     ASSERT(m_document);
 }
 
-void XSSAuditorDelegate::didBlockScript(PassOwnPtr<DidBlockScriptRequest> request)
+void XSSAuditorDelegate::didBlockScript(const XSSInfo& xssInfo)
 {
     ASSERT(isMainThread());
 
@@ -54,27 +62,27 @@
     DEFINE_STATIC_LOCAL(String, consoleMessage, (ASCIILiteral("Refused to execute a _javascript_ script. Source code of script found within request.\n")));
     m_document->addConsoleMessage(JSMessageSource, ErrorMessageLevel, consoleMessage);
 
-    if (request->m_didBlockEntirePage)
+    if (xssInfo.m_didBlockEntirePage)
         m_document->frame()->loader()->stopAllLoaders();
 
     if (!m_didNotifyClient) {
-        m_document->frame()->loader()->client()->didDetectXSS(m_document->url(), request->m_didBlockEntirePage);
+        m_document->frame()->loader()->client()->didDetectXSS(m_document->url(), xssInfo.m_didBlockEntirePage);
         m_didNotifyClient = true;
     }
 
-    if (!request->m_reportURL.isEmpty()) {
+    if (!xssInfo.m_reportURL.isEmpty()) {
         RefPtr<InspectorObject> reportDetails = InspectorObject::create();
-        reportDetails->setString("request-url", request->m_originalURL);
-        reportDetails->setString("request-body", request->m_originalHTTPBody);
+        reportDetails->setString("request-url", xssInfo.m_originalURL);
+        reportDetails->setString("request-body", xssInfo.m_originalHTTPBody);
 
         RefPtr<InspectorObject> reportObject = InspectorObject::create();
         reportObject->setObject("xss-report", reportDetails.release());
 
         RefPtr<FormData> report = FormData::create(reportObject->toJSONString().utf8().data());
-        PingLoader::sendViolationReport(m_document->frame(), request->m_reportURL, report);
+        PingLoader::sendViolationReport(m_document->frame(), xssInfo.m_reportURL, report);
     }
 
-    if (request->m_didBlockEntirePage)
+    if (xssInfo.m_didBlockEntirePage)
         m_document->frame()->navigationScheduler()->scheduleLocationChange(m_document->securityOrigin(), blankURL(), String());
 }
 

Modified: trunk/Source/WebCore/html/parser/XSSAuditorDelegate.h (141904 => 141905)


--- trunk/Source/WebCore/html/parser/XSSAuditorDelegate.h	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WebCore/html/parser/XSSAuditorDelegate.h	2013-02-05 19:06:26 UTC (rev 141905)
@@ -34,20 +34,22 @@
 
 class Document;
 
-class DidBlockScriptRequest {
+class XSSInfo {
 public:
-    static PassOwnPtr<DidBlockScriptRequest> create(const KURL& reportURL, const String& originalURL, const String& originalHTTPBody, bool didBlockEntirePage)
+    static PassOwnPtr<XSSInfo> create(const KURL& reportURL, const String& originalURL, const String& originalHTTPBody, bool didBlockEntirePage)
     {
-        return adoptPtr(new DidBlockScriptRequest(reportURL, originalURL, originalHTTPBody, didBlockEntirePage));
+        return adoptPtr(new XSSInfo(reportURL, originalURL, originalHTTPBody, didBlockEntirePage));
     }
 
+    bool isSafeToSendToAnotherThread() const;
+
     KURL m_reportURL;
     String m_originalURL;
     String m_originalHTTPBody;
     bool m_didBlockEntirePage;
 
 private:
-    DidBlockScriptRequest(const KURL& reportURL, const String& originalURL, const String& originalHTTPBody, bool didBlockEntirePage)
+    XSSInfo(const KURL& reportURL, const String& originalURL, const String& originalHTTPBody, bool didBlockEntirePage)
         : m_reportURL(reportURL)
         , m_originalURL(originalURL)
         , m_originalHTTPBody(originalHTTPBody)
@@ -60,7 +62,7 @@
 public:
     explicit XSSAuditorDelegate(Document*);
 
-    void didBlockScript(PassOwnPtr<DidBlockScriptRequest>);
+    void didBlockScript(const XSSInfo&);
 
 private:
     Document* m_document;

Modified: trunk/Source/WebCore/platform/KURL.cpp (141904 => 141905)


--- trunk/Source/WebCore/platform/KURL.cpp	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WebCore/platform/KURL.cpp	2013-02-05 19:06:26 UTC (rev 141905)
@@ -1935,4 +1935,15 @@
 #endif
 }
 
+bool KURL::isSafeToSendToAnotherThread() const
+{
+#if USE(GOOGLEURL)
+    return m_url.isSafeToSendToAnotherThread();
+#elif USE(WTFURL)
+    return m_urlImpl.isSafeToSendToAnotherThread();
+#else // !USE(GOOGLEURL)
+    return m_string.isSafeToSendToAnotherThread();
+#endif
 }
+
+}

Modified: trunk/Source/WebCore/platform/KURL.h (141904 => 141905)


--- trunk/Source/WebCore/platform/KURL.h	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WebCore/platform/KURL.h	2013-02-05 19:06:26 UTC (rev 141905)
@@ -227,6 +227,7 @@
 #endif
 
     void reportMemoryUsage(MemoryObjectInfo*) const;
+    bool isSafeToSendToAnotherThread() const;
 
 private:
     void invalidate();

Modified: trunk/Source/WebCore/platform/KURLGoogle.cpp (141904 => 141905)


--- trunk/Source/WebCore/platform/KURLGoogle.cpp	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WebCore/platform/KURLGoogle.cpp	2013-02-05 19:06:26 UTC (rev 141905)
@@ -399,6 +399,14 @@
     info.addMember(m_innerURL, "innerURL");
     info.addMember(m_parsed, "parsed");
 }
+
+bool KURLGooglePrivate::isSafeToSendToAnotherThread() const
+{
+    return m_string.isSafeToSendToAnotherThread()
+        && m_utf8.isSafeToSendToAnotherThread()
+        && (!m_innerURL || m_innerURL->isSafeToSendToAnotherThread());
+}
+
 // KURL ------------------------------------------------------------------------
 
 // Initializes with a string representing an absolute URL. No encoding

Modified: trunk/Source/WebCore/platform/KURLGooglePrivate.h (141904 => 141905)


--- trunk/Source/WebCore/platform/KURLGooglePrivate.h	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WebCore/platform/KURLGooglePrivate.h	2013-02-05 19:06:26 UTC (rev 141905)
@@ -101,6 +101,7 @@
         KURL* innerURL() const { return m_innerURL.get(); }
 
         void reportMemoryUsage(MemoryObjectInfo*) const;
+        bool isSafeToSendToAnotherThread() const;
 
     private:
         void initInnerURL();

Modified: trunk/Source/WebCore/platform/KURLWTFURLImpl.h (141904 => 141905)


--- trunk/Source/WebCore/platform/KURLWTFURLImpl.h	2013-02-05 18:55:57 UTC (rev 141904)
+++ trunk/Source/WebCore/platform/KURLWTFURLImpl.h	2013-02-05 19:06:26 UTC (rev 141905)
@@ -49,6 +49,11 @@
         info.addMember(m_parsedURL, "parsedURL");
         info.addMember(m_invalidUrlString, "invalidUrlString");
     }
+    bool isSafeToSendToAnotherThread() const
+    {
+        return m_invalidUrlString.isSafeToSendToAnotherThread()
+            && m_parsedURL.isSafeToSendToAnotherThread();
+    }
     PassRefPtr<KURLWTFURLImpl> copy() const;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to