Chromium Code Reviews| Index: Source/core/html/parser/XSSAuditor.cpp |
| diff --git a/Source/core/html/parser/XSSAuditor.cpp b/Source/core/html/parser/XSSAuditor.cpp |
| index 0f27adb9a2702709f91855b56171c88164cd807f..3796af9512125f93b8447f3a974ad35ed8b43379 100644 |
| --- a/Source/core/html/parser/XSSAuditor.cpp |
| +++ b/Source/core/html/parser/XSSAuditor.cpp |
| @@ -710,7 +710,15 @@ String XSSAuditor::canonicalize(String snippet, TruncationKind treatment) |
| String decodedSnippet = fullyDecodeString(snippet, m_encoding); |
| if (treatment != NoTruncation) { |
| - decodedSnippet.truncate(kMaximumFragmentLengthTarget); |
| + if (decodedSnippet.length() > kMaximumFragmentLengthTarget) { |
| + // Let the page influence the stopping point to avoid disclosing leading fragments. |
| + // Stop when we hit whitespace, since that is unlikely to be part a leading fragment. |
| + size_t position = kMaximumFragmentLengthTarget; |
| + while (position < decodedSnippet.length() && !isHTMLSpace(decodedSnippet[position])) { |
|
Mike West
2015/06/11 06:01:26
Nit: No {} for single-line clauses.
|
| + ++position; |
| + } |
| + decodedSnippet.truncate(position); |
| + } |
| if (treatment == SrcLikeAttributeTruncation) |
| truncateForSrcLikeAttribute(decodedSnippet); |
| else if (treatment == ScriptLikeAttributeTruncation) |