Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Unified Diff: Source/core/html/parser/XSSAuditor.cpp

Issue 74513003: Moved text decoding to the parser thread (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@parserthread_step25
Patch Set: XSSAuditor fix Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/html/parser/XSSAuditor.cpp
diff --git a/Source/core/html/parser/XSSAuditor.cpp b/Source/core/html/parser/XSSAuditor.cpp
index b7565af670598bb066bc5a0bf2c956de52b22c42..4e0f1852f71d1f8fde4ccc3b3ee60850d05fcfd9 100644
--- a/Source/core/html/parser/XSSAuditor.cpp
+++ b/Source/core/html/parser/XSSAuditor.cpp
@@ -222,9 +222,6 @@ void XSSAuditor::initForFragment()
void XSSAuditor::init(Document* document, XSSAuditorDelegate* auditorDelegate)
{
- const size_t miniumLengthForSuffixTree = 512; // FIXME: Tune this parameter.
- const int suffixTreeDepth = 5;
-
ASSERT(isMainThread());
if (m_state != Uninitialized)
return;
@@ -259,11 +256,6 @@ void XSSAuditor::init(Document* document, XSSAuditorDelegate* auditorDelegate)
if (document->encoding().isValid())
m_encoding = document->encoding();
- m_decodedURL = fullyDecodeString(m_documentURL.string(), m_encoding);
- if (m_decodedURL.find(isRequiredForInjection) == kNotFound)
- m_decodedURL = String();
-
- String httpBodyAsString;
if (DocumentLoader* documentLoader = document->frame()->loader().documentLoader()) {
DEFINE_STATIC_LOCAL(String, XSSProtectionHeader, ("X-XSS-Protection"));
String headerValue = documentLoader->response().httpHeaderField(XSSProtectionHeader);
@@ -294,22 +286,37 @@ void XSSAuditor::init(Document* document, XSSAuditorDelegate* auditorDelegate)
if (auditorDelegate)
auditorDelegate->setReportURL(xssProtectionReportURL.copy());
FormData* httpBody = documentLoader->originalRequest().httpBody();
- if (httpBody && !httpBody->isEmpty()) {
- httpBodyAsString = httpBody->flattenToString();
- if (!httpBodyAsString.isEmpty()) {
- m_decodedHTTPBody = fullyDecodeString(httpBodyAsString, m_encoding);
- if (m_decodedHTTPBody.find(isRequiredForInjection) == kNotFound)
- m_decodedHTTPBody = String();
- if (m_decodedHTTPBody.length() >= miniumLengthForSuffixTree)
- m_decodedHTTPBodySuffixTree = adoptPtr(new SuffixTree<ASCIICodebook>(m_decodedHTTPBody, suffixTreeDepth));
- }
- }
+ if (httpBody && !httpBody->isEmpty())
+ m_httpBodyAsString = httpBody->flattenToString();
}
- if (m_decodedURL.isEmpty() && m_decodedHTTPBody.isEmpty()) {
- m_isEnabled = false;
+ setEncoding(m_encoding);
+}
+
+void XSSAuditor::setEncoding(const WTF::TextEncoding& encoding)
+{
+ const size_t miniumLengthForSuffixTree = 512; // FIXME: Tune this parameter.
+ const int suffixTreeDepth = 5;
+
+ if (!encoding.isValid())
return;
+
+ m_encoding = encoding;
+
+ m_decodedURL = fullyDecodeString(m_documentURL.string(), m_encoding);
+ if (m_decodedURL.find(isRequiredForInjection) == kNotFound)
+ m_decodedURL = String();
+
+ if (!m_httpBodyAsString.isEmpty()) {
abarth-chromium 2013/11/25 21:45:40 Should we clear out m_httpBodyAsString after this
oystein (OOO til 10th of July) 2013/11/27 00:47:30 Actually I meant to ask about that; there's some l
+ m_decodedHTTPBody = fullyDecodeString(m_httpBodyAsString, m_encoding);
+ if (m_decodedHTTPBody.find(isRequiredForInjection) == kNotFound)
+ m_decodedHTTPBody = String();
+ if (m_decodedHTTPBody.length() >= miniumLengthForSuffixTree)
+ m_decodedHTTPBodySuffixTree = adoptPtr(new SuffixTree<ASCIICodebook>(m_decodedHTTPBody, suffixTreeDepth));
}
+
+ if (m_decodedURL.isEmpty() && m_decodedHTTPBody.isEmpty())
+ m_isEnabled = false;
}
PassOwnPtr<XSSInfo> XSSAuditor::filterToken(const FilterTokenRequest& request)

Powered by Google App Engine
This is Rietveld 408576698