Skip to content

Commit 44f02f6

Browse files
fix: hex-encode Windows notification icon temp filenames (#50484)
* fix: hex-encode Windows notification icon temp filenames NotificationPresenterWin was using SHA1HashString(origin.spec()) directly as the basename for the temporary PNG written for toast icons. SHA1HashString returns raw digest bytes, so the generated filename could contain invalid path characters on Windows. That caused WriteFile to fail when saving notification icons, which left toast XML without the expected icon path. Hex-encode the digest before appending .png so the temporary filename is filesystem-safe while keeping deterministic naming for a given origin. Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * Update shell/browser/notifications/win/notification_presenter_win.cc Co-authored-by: Robo <hop2deep@gmail.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
1 parent 904fbbd commit 44f02f6

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

shell/browser/notifications/win/notification_presenter_win.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ std::wstring NotificationPresenterWin::SaveIconToFilesystem(
7272

7373
std::string filename;
7474
if (origin.is_valid()) {
75-
filename = base::SHA1HashString(origin.spec()) + ".png";
75+
const auto hash = base::SHA1HashString(origin.spec());
76+
filename = base::HexEncode(hash) + ".png";
7677
} else {
7778
const int64_t now_usec = base::Time::Now().since_origin().InMicroseconds();
7879
filename = base::NumberToString(now_usec) + ".png";

0 commit comments

Comments
 (0)