Do not sanitize about:blank/#foo & about:blank?foo
This CL ensures that the browser will not sanitize these two types of
URLs. This fixes an issue with PlzNavigate where we could not go back to
about:blank/#foo due to some discrepancy between the url in the
FrameNavigationEntry & the url stored in the PageState of the same
entry.
BUG=575210
Review-Url: https://codereview.chromium.org/2644133002
Cr-Commit-Position: refs/heads/master@{#445525}
diff --git a/url/url_util.cc b/url/url_util.cc
index 2c8d697..9a2cce4 100644
--- a/url/url_util.cc
+++ b/url/url_util.cc
@@ -10,6 +10,7 @@
#include "base/debug/leak_annotations.h"
#include "base/logging.h"
#include "base/strings/string_util.h"
+#include "url/gurl.h"
#include "url/url_canon_internal.h"
#include "url/url_constants.h"
#include "url/url_file.h"
@@ -608,6 +609,21 @@
return DoIsInSchemes(spec, scheme, &unused_scheme_type, *referrer_schemes);
}
+bool IsAboutBlank(const GURL& url) {
+ if (!url.SchemeIs(url::kAboutScheme))
+ return false;
+
+ if (url.has_host() || url.has_username() || url.has_password() ||
+ url.has_port()) {
+ return false;
+ }
+
+ if (url.path() != kAboutBlankPath && url.path() != kAboutBlankWithHashPath)
+ return false;
+
+ return true;
+}
+
bool FindAndCompareScheme(const char* str,
int str_len,
const char* compare,