Pier Angelo Vendrame pushed to branch base-browser-128.3.0esr-14.0-1 at The Tor Project / Applications / Tor Browser
Commits: febfa1bf by rahulsainani at 2024-10-14T16:07:55+02:00 Bug 1906024 - Format download file names better a=diannaS
Original Revision: https://phabricator.services.mozilla.com/D220559
Differential Revision: https://phabricator.services.mozilla.com/D222254
- - - - - 0caad63c by rahulsainani at 2024-10-14T16:08:09+02:00 Bug 1906024 - Format download file names a=diannaS
Original Revision: https://phabricator.services.mozilla.com/D221771
Differential Revision: https://phabricator.services.mozilla.com/D222259 - - - - - 796fd9d6 by Pier Angelo Vendrame at 2024-10-14T16:08:30+02:00 Bug 43196: Remove the vendor name from media notifications on Linux.
Firefox shows "vendor remoteName" as a title of the "... is playing media" notification on Linux. However, for our browser the remote name is enough, and prepending the vendor to it creates a string users usually never see.
- - - - -
3 changed files:
- mobile/android/android-components/components/support/ktx/src/main/java/mozilla/components/support/ktx/kotlin/String.kt - mobile/android/android-components/components/support/ktx/src/test/java/mozilla/components/support/ktx/kotlin/StringTest.kt - widget/gtk/MPRISServiceHandler.cpp
Changes:
===================================== mobile/android/android-components/components/support/ktx/src/main/java/mozilla/components/support/ktx/kotlin/String.kt ===================================== @@ -53,6 +53,8 @@ const val MAX_URI_LENGTH = 25000
private const val FILE_PREFIX = "file://" private const val MAX_VALID_PORT = 65_535 +private const val SPACE = " " +private const val UNDERSCORE = "_"
/** * Shortens URLs to be more user friendly. @@ -307,7 +309,9 @@ fun String.sanitizeFileName(): String { file.name.replace("\.\.+".toRegex(), ".") } else { file.name.replace(".", "") - }.replaceEscapedCharacters() + }.replaceContinuousSpaces() + .replaceEscapedCharacters() + .trim() }
/** @@ -315,8 +319,16 @@ fun String.sanitizeFileName(): String { * and is correctly displayed. */ private fun String.replaceEscapedCharacters(): String { - val controlCharactersRegex = "[\x00-\x13/*"?<>:|\\]".toRegex() - return replace(controlCharactersRegex, "_") + val escapedCharactersRegex = "[\x00-\x13*"?<>:|\\]".toRegex() + return replace(escapedCharactersRegex, UNDERSCORE) +} + +/** + * Replaces continuous spaces with a single space. + */ +private fun String.replaceContinuousSpaces(): String { + val escapedCharactersRegex = "[\p{Z}\s]+".toRegex() + return replace(escapedCharactersRegex, SPACE) }
/**
===================================== mobile/android/android-components/components/support/ktx/src/test/java/mozilla/components/support/ktx/kotlin/StringTest.kt ===================================== @@ -199,11 +199,11 @@ class StringTest { "acknowledge\u0006signal" to "acknowledge_signal", "bell\u0007sound" to "bell_sound", "back\u0008space" to "back_space", - "horizontal\u0009tab" to "horizontal_tab", - "new\u000Aline" to "new_line", - "vertical\u000Btab" to "vertical_tab", - "form\u000Cfeed" to "form_feed", - "return\u000Dcarriage" to "return_carriage", + "horizontal\u0009tab" to "horizontal tab", + "new\u000Aline" to "new line", + "vertical\u000Btab" to "vertical tab", + "form\u000Cfeed" to "form feed", + "return\u000Dcarriage" to "return carriage", "shift\u000Eout" to "shift_out", "shift\u000Fin" to "shift_in", "escape\u0010data" to "escape_data",
===================================== widget/gtk/MPRISServiceHandler.cpp ===================================== @@ -414,8 +414,10 @@ void MPRISServiceHandler::InitIdentity() { do_GetService("@mozilla.org/xre/app-info;1", &rv); MOZ_ASSERT(NS_SUCCEEDED(rv));
+#ifndef BASE_BROWSER_VERSION rv = appInfo->GetVendor(mIdentity); MOZ_ASSERT(NS_SUCCEEDED(rv)); +#endif
if (gAppData) { mDesktopEntry = gAppData->remotingName; @@ -424,7 +426,9 @@ void MPRISServiceHandler::InitIdentity() { MOZ_ASSERT(NS_SUCCEEDED(rv)); }
+#ifndef BASE_BROWSER_VERSION mIdentity.Append(' '); +#endif mIdentity.Append(mDesktopEntry);
// Compute the desktop entry name like nsAppRunner does for g_set_prgname
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/bdea242...