1193
|
1 |
# HG changeset patch
|
|
2 |
# User Rob Krum <biggestsonicfan@gmail.com>
|
|
3 |
# Date 1695432215 25200
|
|
4 |
# Fri Sep 22 18:23:35 2023 -0700
|
|
5 |
# Node ID e6a8a9f0956d124e8de34eb4bcf09d8e17077d9d
|
1200
|
6 |
# Parent 5dbbabbfaca21d2c5994f95ed095313284611c44
|
1193
|
7 |
Bug 1822730 - Add basic blob protocol handling for blob URIs that contain parsable http/s protocols
|
|
8 |
|
|
9 |
diff --git a/toolkit/mozapps/downloads/DownloadLastDir.sys.mjs b/toolkit/mozapps/downloads/DownloadLastDir.sys.mjs
|
|
10 |
--- a/toolkit/mozapps/downloads/DownloadLastDir.sys.mjs
|
|
11 |
+++ b/toolkit/mozapps/downloads/DownloadLastDir.sys.mjs
|
1200
|
12 |
@@ -216,38 +216,49 @@ export class DownloadLastDir {
|
|
13 |
Services.prefs.setComplexValue(LAST_DIR_PREF, nsIFile, aFile);
|
|
14 |
} else if (Services.prefs.prefHasUserValue(LAST_DIR_PREF)) {
|
|
15 |
Services.prefs.clearUserPref(LAST_DIR_PREF);
|
|
16 |
}
|
|
17 |
}
|
1193
|
18 |
|
|
19 |
/**
|
|
20 |
* Pre-processor to extract a domain name to be used with the content-prefs
|
|
21 |
- * service. This specially handles data and file URIs so that the download
|
|
22 |
- * dirs are recalled in a more consistent way:
|
|
23 |
+ * service. This specially handles data, file and blob URIs so that the
|
|
24 |
+ * download dirs are recalled in a more consistent way:
|
|
25 |
* - all file:/// URIs share the same folder
|
|
26 |
* - data: URIs share a folder per mime-type. If a mime-type is not
|
|
27 |
* specified text/plain is assumed.
|
1200
|
28 |
* - blob: URIs share the same folder as their origin. This is done by
|
|
29 |
* ContentPrefs already, so we just let the url fall-through.
|
1193
|
30 |
* In any other case the original URL is returned as a string and ContentPrefs
|
|
31 |
* will do its usual parsing.
|
|
32 |
*
|
1200
|
33 |
* @param {string|nsIURI|URL} url The URL to parse
|
|
34 |
* @returns {string} the domain name to use, or the original url.
|
1193
|
35 |
*/
|
|
36 |
#cpsGroupFromURL(url) {
|
|
37 |
if (typeof url == "string") {
|
|
38 |
+ if (url.startsWith("blob:http://") || url.startsWith("blob:https://")) {
|
|
39 |
+ url = url.replace("blob:", "");
|
|
40 |
+ }
|
|
41 |
url = new URL(url);
|
|
42 |
} else if (url instanceof Ci.nsIURI) {
|
|
43 |
url = URL.fromURI(url);
|
1200
|
44 |
}
|
1193
|
45 |
if (!URL.isInstance(url)) {
|
|
46 |
return url;
|
|
47 |
}
|
|
48 |
+ if (url.protocol == "blob:") {
|
|
49 |
+ if (
|
|
50 |
+ url.href.startsWith("blob:http://") ||
|
|
51 |
+ url.href.startsWith("blob:https://")
|
|
52 |
+ ) {
|
|
53 |
+ return url.href.replace("blob:", "");
|
|
54 |
+ }
|
|
55 |
+ }
|
|
56 |
if (url.protocol == "data:") {
|
|
57 |
return url.href.match(/^data:[^;,]*/i)[0].replace(/:$/, ":text/plain");
|
|
58 |
}
|
1200
|
59 |
if (url.protocol == "file:") {
|
|
60 |
return "file:///";
|
|
61 |
}
|
|
62 |
return url.href;
|
|
63 |
}
|