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:
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 |
53
|
53
|
|
54
|
54
|
private const val FILE_PREFIX = "file://"
|
55
|
55
|
private const val MAX_VALID_PORT = 65_535
|
|
56
|
+private const val SPACE = " "
|
|
57
|
+private const val UNDERSCORE = "_"
|
56
|
58
|
|
57
|
59
|
/**
|
58
|
60
|
* Shortens URLs to be more user friendly.
|
... |
... |
@@ -307,7 +309,9 @@ fun String.sanitizeFileName(): String { |
307
|
309
|
file.name.replace("\\.\\.+".toRegex(), ".")
|
308
|
310
|
} else {
|
309
|
311
|
file.name.replace(".", "")
|
310
|
|
- }.replaceEscapedCharacters()
|
|
312
|
+ }.replaceContinuousSpaces()
|
|
313
|
+ .replaceEscapedCharacters()
|
|
314
|
+ .trim()
|
311
|
315
|
}
|
312
|
316
|
|
313
|
317
|
/**
|
... |
... |
@@ -315,8 +319,16 @@ fun String.sanitizeFileName(): String { |
315
|
319
|
* and is correctly displayed.
|
316
|
320
|
*/
|
317
|
321
|
private fun String.replaceEscapedCharacters(): String {
|
318
|
|
- val controlCharactersRegex = "[\\x00-\\x13/*\"?<>:|\\\\]".toRegex()
|
319
|
|
- return replace(controlCharactersRegex, "_")
|
|
322
|
+ val escapedCharactersRegex = "[\\x00-\\x13*\"?<>:|\\\\]".toRegex()
|
|
323
|
+ return replace(escapedCharactersRegex, UNDERSCORE)
|
|
324
|
+}
|
|
325
|
+
|
|
326
|
+/**
|
|
327
|
+ * Replaces continuous spaces with a single space.
|
|
328
|
+ */
|
|
329
|
+private fun String.replaceContinuousSpaces(): String {
|
|
330
|
+ val escapedCharactersRegex = "[\\p{Z}\\s]+".toRegex()
|
|
331
|
+ return replace(escapedCharactersRegex, SPACE)
|
320
|
332
|
}
|
321
|
333
|
|
322
|
334
|
/**
|
mobile/android/android-components/components/support/ktx/src/test/java/mozilla/components/support/ktx/kotlin/StringTest.kt
... |
... |
@@ -199,11 +199,11 @@ class StringTest { |
199
|
199
|
"acknowledge\u0006signal" to "acknowledge_signal",
|
200
|
200
|
"bell\u0007sound" to "bell_sound",
|
201
|
201
|
"back\u0008space" to "back_space",
|
202
|
|
- "horizontal\u0009tab" to "horizontal_tab",
|
203
|
|
- "new\u000Aline" to "new_line",
|
204
|
|
- "vertical\u000Btab" to "vertical_tab",
|
205
|
|
- "form\u000Cfeed" to "form_feed",
|
206
|
|
- "return\u000Dcarriage" to "return_carriage",
|
|
202
|
+ "horizontal\u0009tab" to "horizontal tab",
|
|
203
|
+ "new\u000Aline" to "new line",
|
|
204
|
+ "vertical\u000Btab" to "vertical tab",
|
|
205
|
+ "form\u000Cfeed" to "form feed",
|
|
206
|
+ "return\u000Dcarriage" to "return carriage",
|
207
|
207
|
"shift\u000Eout" to "shift_out",
|
208
|
208
|
"shift\u000Fin" to "shift_in",
|
209
|
209
|
"escape\u0010data" to "escape_data",
|
widget/gtk/MPRISServiceHandler.cpp
... |
... |
@@ -414,8 +414,10 @@ void MPRISServiceHandler::InitIdentity() { |
414
|
414
|
do_GetService("@mozilla.org/xre/app-info;1", &rv);
|
415
|
415
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
416
|
416
|
|
|
417
|
+#ifndef BASE_BROWSER_VERSION
|
417
|
418
|
rv = appInfo->GetVendor(mIdentity);
|
418
|
419
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
|
420
|
+#endif
|
419
|
421
|
|
420
|
422
|
if (gAppData) {
|
421
|
423
|
mDesktopEntry = gAppData->remotingName;
|
... |
... |
@@ -424,7 +426,9 @@ void MPRISServiceHandler::InitIdentity() { |
424
|
426
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
425
|
427
|
}
|
426
|
428
|
|
|
429
|
+#ifndef BASE_BROWSER_VERSION
|
427
|
430
|
mIdentity.Append(' ');
|
|
431
|
+#endif
|
428
|
432
|
mIdentity.Append(mDesktopEntry);
|
429
|
433
|
|
430
|
434
|
// Compute the desktop entry name like nsAppRunner does for g_set_prgname
|
|