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