tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit a1cc6f93467ab4ef6f9a517ec43dceb61675ec68
parent 7d653e24b3b136314438b3cace0c2c21b688c280
Author: Tom Schuster <tschuster@mozilla.com>
Date:   Mon,  6 Oct 2025 15:32:22 +0000

Bug 1992734 - Sanitizer: In "canonicalize a sanitizer name" the namespace always exists. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D267609

Diffstat:
Mdom/security/sanitizer/Sanitizer.cpp | 30++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/dom/security/sanitizer/Sanitizer.cpp b/dom/security/sanitizer/Sanitizer.cpp @@ -222,26 +222,20 @@ static CanonicalName CanonicalizeElement(const SanitizerElement& aElement) { return CanonicalName(nameAtom, nsGkAtoms::nsuri_xhtml); } - // Step 3. Assert: name is a dictionary and name["name"] exists. + // Step 3. Assert: name is a dictionary and both name["name"] and + // name["namespace"] exist. const auto& elem = GetAsSanitizerElementNamespace(aElement); MOZ_ASSERT(!elem.mName.IsVoid()); + // Step 4. If name["namespace"] is the empty string, then set it to null. RefPtr<nsAtom> namespaceAtom; - // Step 4. Let namespace be name["namespace"] if it exists, otherwise - // defaultNamespace. - // - // Note: "namespace" always exists due to the WebIDL default value. - // https://github.com/WICG/sanitizer-api/issues/310 - // - // Step 5. If namespace is the empty string, then set it to null. - // defaultNamespace. if (!elem.mNamespace.IsEmpty()) { namespaceAtom = NS_AtomizeMainThread(elem.mNamespace); } - // Step 6. Return «[ + // Step 5. Return «[ // "name" → name["name"], - // "namespace" → namespace + // "namespace" → name["namespace"] // ) // ]». RefPtr<nsAtom> nameAtom = NS_AtomizeMainThread(elem.mName); @@ -265,24 +259,20 @@ static CanonicalName CanonicalizeAttribute( return CanonicalName(nameAtom, nullptr); } - // Step 3. Assert: name is a dictionary and name["name"] exists. + // Step 3. Assert: name is a dictionary and both name["name"] and + // name["namespace"] exist. const auto& attr = aAttribute.GetAsSanitizerAttributeNamespace(); MOZ_ASSERT(!attr.mName.IsVoid()); + // Step 4. If name["namespace"] is the empty string, then set it to null. RefPtr<nsAtom> namespaceAtom; - // Step 4. Let namespace be name["namespace"] if it exists, otherwise - // defaultNamespace. - // https://github.com/WICG/sanitizer-api/issues/310 - - // Step 5. If namespace is the empty string, then set it to - // null. if (!attr.mNamespace.IsEmpty()) { namespaceAtom = NS_AtomizeMainThread(attr.mNamespace); } - // Step 6. Return «[ + // Step 5. Return «[ // "name" → name["name"], - // "namespace" → namespace, + // "namespace" → name["namespace"], // ) // ]». RefPtr<nsAtom> nameAtom = NS_AtomizeMainThread(attr.mName);