Commit a1886ef5 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Replace slashes in printing::SimplifyDocumentTitleWithLength().

Currently, the function replaces backslashes with underscores. Do the
same for forward slashes.

Bug: 1041897
Change-Id: I2063992a093d3a8f10f71b452617313783b6bcd1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2036352Reviewed-by: default avatarWill Harris <wfh@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737879}
parent 43ad0b81
...@@ -35,6 +35,8 @@ base::string16 SimplifyDocumentTitleWithLength(const base::string16& title, ...@@ -35,6 +35,8 @@ base::string16 SimplifyDocumentTitleWithLength(const base::string16& title,
no_controls.end()); no_controls.end());
base::ReplaceChars(no_controls, base::ASCIIToUTF16("\\"), base::ReplaceChars(no_controls, base::ASCIIToUTF16("\\"),
base::ASCIIToUTF16("_"), &no_controls); base::ASCIIToUTF16("_"), &no_controls);
base::ReplaceChars(no_controls, base::ASCIIToUTF16("/"),
base::ASCIIToUTF16("_"), &no_controls);
base::string16 result; base::string16 result;
gfx::ElideString(no_controls, length, &result); gfx::ElideString(no_controls, length, &result);
return result; return result;
......
...@@ -39,6 +39,7 @@ TEST(PrintingUtilsTest, SimplifyDocumentTitle) { ...@@ -39,6 +39,7 @@ TEST(PrintingUtilsTest, SimplifyDocumentTitle) {
EXPECT_EQ("abc...ij", Simplify("abcdefghij")); EXPECT_EQ("abc...ij", Simplify("abcdefghij"));
EXPECT_EQ("Controls", Simplify("C\ron\nt\15rols")); EXPECT_EQ("Controls", Simplify("C\ron\nt\15rols"));
EXPECT_EQ("C:_foo_", Simplify("C:\\foo\\")); EXPECT_EQ("C:_foo_", Simplify("C:\\foo\\"));
EXPECT_EQ("C:_foo_", Simplify("C:/foo/"));
EXPECT_EQ("", Simplify("\n\r\n\r\t\r")); EXPECT_EQ("", Simplify("\n\r\n\r\t\r"));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment