summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/BookmarkJSONUtils.sys.mjs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
commit40a355a42d4a9444dc753c04c6608dade2f06a23 (patch)
tree871fc667d2de662f171103ce5ec067014ef85e61 /toolkit/components/places/BookmarkJSONUtils.sys.mjs
parentAdding upstream version 124.0.1. (diff)
downloadfirefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz
firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/places/BookmarkJSONUtils.sys.mjs')
-rw-r--r--toolkit/components/places/BookmarkJSONUtils.sys.mjs23
1 files changed, 2 insertions, 21 deletions
diff --git a/toolkit/components/places/BookmarkJSONUtils.sys.mjs b/toolkit/components/places/BookmarkJSONUtils.sys.mjs
index 29967b5395..0a27db3696 100644
--- a/toolkit/components/places/BookmarkJSONUtils.sys.mjs
+++ b/toolkit/components/places/BookmarkJSONUtils.sys.mjs
@@ -21,26 +21,6 @@ const OLD_BOOKMARK_QUERY_TRANSLATIONS = {
MOBILE_BOOKMARKS: PlacesUtils.bookmarks.mobileGuid,
};
-/**
- * Generates an hash for the given string.
- *
- * @note The generated hash is returned in base64 form. Mind the fact base64
- * is case-sensitive if you are going to reuse this code.
- */
-function generateHash(aString) {
- let cryptoHash = Cc["@mozilla.org/security/hash;1"].createInstance(
- Ci.nsICryptoHash
- );
- cryptoHash.init(Ci.nsICryptoHash.MD5);
- let stringStream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(
- Ci.nsIStringInputStream
- );
- stringStream.setUTF8Data(aString);
- cryptoHash.updateFromStream(stringStream, -1);
- // base64 allows the '/' char, but we can't use it for filenames.
- return cryptoHash.finish(true).replace(/\//g, "-");
-}
-
export var BookmarkJSONUtils = Object.freeze({
/**
* Import bookmarks from a url.
@@ -164,7 +144,8 @@ export var BookmarkJSONUtils = Object.freeze({
console.error("Unable to report telemetry.");
}
- let hash = generateHash(jsonString);
+ // Use "base64url" as this may be part of a filename.
+ let hash = PlacesUtils.sha256(jsonString, { format: "base64url" });
if (hash === aOptions.failIfHashIs) {
let e = new Error("Hash conflict");