Index: Source/core/html/parser/XSSAuditor.cpp |
diff --git a/Source/core/html/parser/XSSAuditor.cpp b/Source/core/html/parser/XSSAuditor.cpp |
index a1e1852201d23ac858c3b5065a2e26f52d128f4d..e73259145366c12c821a710fe83d3637529478ee 100644 |
--- a/Source/core/html/parser/XSSAuditor.cpp |
+++ b/Source/core/html/parser/XSSAuditor.cpp |
@@ -471,15 +471,18 @@ bool XSSAuditor::filterCharacterToken(const FilterTokenRequest& request) |
if (m_state == PermittingAdjacentCharacterTokens) |
return false; |
- if ((m_state == SuppressingAdjacentCharacterTokens) |
- || (m_scriptTagFoundInRequest && isContainedInRequest(canonicalizedSnippetForJavaScript(request)))) { |
+ if (m_state == FilteringTokens && m_scriptTagFoundInRequest) { |
+ String snippet = canonicalizedSnippetForJavaScript(request); |
+ if (isContainedInRequest(snippet)) |
+ m_state = SuppressingAdjacentCharacterTokens; |
+ else if (!snippet.isEmpty()) |
+ m_state = PermittingAdjacentCharacterTokens; |
+ } |
+ if (m_state == SuppressingAdjacentCharacterTokens) { |
request.token.eraseCharacters(); |
request.token.appendToCharacter(' '); // Technically, character tokens can't be empty. |
- m_state = SuppressingAdjacentCharacterTokens; |
return true; |
} |
- |
- m_state = PermittingAdjacentCharacterTokens; |
return false; |
} |