diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
commit | 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch) | |
tree | a4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /toolkit/components/places/BookmarkJSONUtils.sys.mjs | |
parent | Adding debian version 124.0.1-1. (diff) | |
download | firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip |
Merging upstream version 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.mjs | 23 |
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"); |