0

Fix generated Save As filename for HTTPS websites

This CL makes the URL title check in GenerateFilename() match the
simplified format from https://crrev.com/1125779. This makes it
correctly detect these URL-derived titles for HTTPS websites, which
makes it return the expected filename rather than the full URL title.

Bug: 1463213
Change-Id: I48b9860842dd03eb92a0ae02579f200cddab7c9c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4763431
Reviewed-by: Min Qin <qinmin@chromium.org>
Commit-Queue: Min Qin <qinmin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1181755}
This commit is contained in:
Jackson Loeffler
2023-08-09 23:24:16 +00:00
committed by Chromium LUCI CQ
parent 82f8717589
commit a73d2dfda3

@ -116,7 +116,12 @@ base::FilePath GenerateFilename(const std::u16string& title,
// back to a URL, and if it matches the original page URL, we know the page
// had no title (or had a title equal to its URL, which is fine to treat
// similarly).
if (title == url_formatter::FormatUrl(url)) {
if (title == url_formatter::FormatUrl(
url,
url_formatter::kFormatUrlOmitDefaults |
url_formatter::kFormatUrlOmitTrivialSubdomains |
url_formatter::kFormatUrlOmitHTTPS,
base::UnescapeRule::SPACES, nullptr, nullptr, nullptr)) {
std::string url_path;
if (!url.SchemeIs(url::kDataScheme)) {
name_with_proper_ext = net::GenerateFileName(