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

Unified Diff: url/url_canon_etc.cc

Issue 2895953002: Update dangling markup mitigations. (Closed)
Patch Set: Test. Created 3 years, 7 months 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: url/url_canon_etc.cc
diff --git a/url/url_canon_etc.cc b/url/url_canon_etc.cc
index 9dd40da1624834ea9a3c38b2a5b9c9f6cac31b6b..31e9fb5cfabf7836a6f4bd416f600ec1ac6128f6 100644
--- a/url/url_canon_etc.cc
+++ b/url/url_canon_etc.cc
@@ -22,10 +22,12 @@ inline bool IsRemovableURLWhitespace(int ch) {
// Backend for RemoveURLWhitespace (see declaration in url_canon.h).
// It sucks that we have to do this, since this takes about 13% of the total URL
// canonicalization time.
-template<typename CHAR>
-const CHAR* DoRemoveURLWhitespace(const CHAR* input, int input_len,
+template <typename CHAR>
+const CHAR* DoRemoveURLWhitespace(const CHAR* input,
+ int input_len,
CanonOutputT<CHAR>* buffer,
- int* output_len) {
+ int* output_len,
+ bool* potentially_dangling_markup) {
// Fast verification that there's nothing that needs removal. This is the 99%
// case, so we want it to be fast and don't care about impacting the speed
// when we do find whitespace.
@@ -46,8 +48,11 @@ const CHAR* DoRemoveURLWhitespace(const CHAR* input, int input_len,
// Remove the whitespace into the new buffer and return it.
for (int i = 0; i < input_len; i++) {
- if (!IsRemovableURLWhitespace(input[i]))
+ if (!IsRemovableURLWhitespace(input[i])) {
+ if (potentially_dangling_markup && input[i] == 0x3C)
+ *potentially_dangling_markup = true;
buffer->push_back(input[i]);
+ }
}
*output_len = buffer->length();
return buffer->data();
@@ -274,17 +279,22 @@ void DoCanonicalizeRef(const CHAR* spec,
} // namespace
-const char* RemoveURLWhitespace(const char* input, int input_len,
+const char* RemoveURLWhitespace(const char* input,
+ int input_len,
CanonOutputT<char>* buffer,
- int* output_len) {
- return DoRemoveURLWhitespace(input, input_len, buffer, output_len);
+ int* output_len,
+ bool* potentially_dangling_markup) {
+ return DoRemoveURLWhitespace(input, input_len, buffer, output_len,
+ potentially_dangling_markup);
}
const base::char16* RemoveURLWhitespace(const base::char16* input,
int input_len,
CanonOutputT<base::char16>* buffer,
- int* output_len) {
- return DoRemoveURLWhitespace(input, input_len, buffer, output_len);
+ int* output_len,
+ bool* potentially_dangling_markup) {
+ return DoRemoveURLWhitespace(input, input_len, buffer, output_len,
+ potentially_dangling_markup);
}
char CanonicalSchemeChar(base::char16 ch) {

Powered by Google App Engine
This is Rietveld 408576698