[tor-commits] [Git][tpo/applications/mullvad-browser][mullvad-browser-128.3.0esr-14.0-1] 3 commits: Bug 1906024 - Format download file names better a=diannaS

Pier Angelo Vendrame (@pierov) git at gitlab.torproject.org
Mon Oct 14 14:09:24 UTC 2024



Pier Angelo Vendrame pushed to branch mullvad-browser-128.3.0esr-14.0-1 at The Tor Project / Applications / Mullvad Browser


Commits:
a21f2f46 by rahulsainani at 2024-10-14T16:09:10+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

- - - - -
f5ad7ff5 by rahulsainani at 2024-10-14T16:09:12+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
- - - - -
24a0b664 by Pier Angelo Vendrame at 2024-10-14T16:09:12+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/mullvad-browser/-/compare/2ad2eec90785888283de5442ee7094951f0df027...24a0b664f9f06c34efa3bd868fb7f95accd8877a

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/compare/2ad2eec90785888283de5442ee7094951f0df027...24a0b664f9f06c34efa3bd868fb7f95accd8877a
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tor-commits/attachments/20241014/c62a4c42/attachment-0001.htm>


More information about the tor-commits mailing list