Skip to content

Firefox 138/139 adds new Sanitizer API behind flag - #26659

Merged
hamishwillee merged 6 commits into
mdn:mainfrom
pepelsbey:sanitizer-api
May 13, 2025
Merged

hamishwillee merged 6 commits into
mdn:mainfrom
pepelsbey:sanitizer-api

Conversation

@pepelsbey

@pepelsbey pepelsbey commented Apr 29, 2025 •

Copy link
Copy Markdown
Member

Summary

⚠️ Work in progress

EDIT.

Test results and supporting details

Not yet implemented "Add a sanitizer option to Element/Shadowroot setHTMLUnsafe() and Document.parseHTMLUnsafe()" - see https://bugzilla.mozilla.org/show_bug.cgi?id=1959727

@github-actions github-actions Bot added data:api Compatibility data for Web API features. https://developer.mozilla.org/docs/Web/API size:l Pull request changing 101-1,000 lines of code. labels Apr 29, 2025
@github-actions

github-actions Bot commented Apr 29, 2025 •

Copy link
Copy Markdown
Contributor

Tip: Review these changes grouped by change (recommended for most PRs), or grouped by feature (for large PRs).

Comment thread api/Sanitizer.json Outdated
"spec_url": "https://wicg.github.io/sanitizer-api/#sanitizer-api",
"support": {
"chrome": {
"version_added": "105",

@hamishwillee hamishwillee May 2, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should start from clean - the reason we deleted this is that too much changed in the spec and we decided to rewrite history that this never existed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed it at BCD meeting and agreed that keeping the history of Chrome supporting the previous version of the spec for a while is still useful. It might be a completely new PR, but some info from this one should be used.

@hamishwillee hamishwillee May 2, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pepelsbey That's a reversion of their previous position, and seems "nuts".

@Elchi3 This makes no sense - no one should be using the older version and we previously agreed it was dead and gone. Trying to build on top of that will make this a very ugly compat story.

If it had been worth keeping, then we would have done so.

@hamishwillee hamishwillee May 6, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From @Elchi3

Not sure. The main argument here is that we violated the BCD removal guidelines. If something was exposed (on by default) to real users, then it can only be removed again from BCD if it is unshipped everywhere for more than two years. Not the case with the Sanitizer API which was on by default in Chrome. I used to think it was fine to make an exception and remove the data but it seems that consumers (web-features) aren't happy when we're not sticking to our own rules 🙂 Also, I thought it was only exposed briefly, but 105-119 is not that brief.

To which I have responded:

I'm OK with living with the exception.
That is after all what Chrome and the spec authors wanted. They reused the API names, but the behaviours are quite different.
I'll stick with not adding the history unless you guys insist.

I see your point, but essentially we made the best decision for 99% of developers.

Comment thread api/Document.json Resolved
Comment thread api/Document.json Resolved
Comment thread api/Document.json Resolved
Comment thread api/ShadowRoot.json Resolved
@hamishwillee
hamishwillee marked this pull request as ready for review May 6, 2025 00:58
@hamishwillee

Copy link
Copy Markdown
Contributor

@Elchi3 I think this is good to review. Removed the web tags, removed the legacy stuff which I hope you won't make me put back in.

@caugner caugner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall, but I think it would be useful to have notes for api.Element.setHTML and api.Sanitizer for chrome mentioning that Chrome 105-118 (incl.) supported a differently specified feature under these names.

@hamishwillee

Copy link
Copy Markdown
Contributor

LGTM overall, but I think it would be useful to have notes for api.Element.setHTML and api.Sanitizer for chrome mentioning that Chrome 105-118 (incl.) supported a differently specified feature under these names.

Good idea. Done in ac5c3bb

Note, that removes a bunch of unrelated MDN URLS. I didn't do that, so it must be something added by the linter at the end.

@hamishwillee
hamishwillee requested a review from caugner May 6, 2025 21:48
@caugner

caugner commented May 7, 2025 •

Copy link
Copy Markdown
Contributor

Note, that removes a bunch of unrelated MDN URLS. I didn't do that, so it must be something added by the linter at the end.

That can happen if your node_modules is out of sync with this branch, which can happen if you git pull on main and this branch is behind.

Edit: I have fixed those now.

@caugner caugner changed the title Add Sanitizer API Firefox 138/139 adds Sanitizer API behind flag May 7, 2025
@caugner caugner changed the title Firefox 138/139 adds Sanitizer API behind flag Firefox 138/139 adds new Sanitizer API behind flag May 7, 2025

@caugner caugner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just two nits.

Comment thread api/Element.json Resolved
Comment thread api/Sanitizer.json Resolved
@caugner

caugner commented May 7, 2025

Copy link
Copy Markdown
Contributor

Given that the MDN pages don't exist yet, I'm holding off on merging until @Elchi3 or @pepelsbey had a final look.

Comment thread api/Sanitizer.json
Comment on lines +7 to +10
"chrome": {
"version_added": false,
"notes": "Chrome 105 to Chrome 118 (inclusive) supported this interface name with a significantly different specification."
},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, what will happen in the future here? Is it this?

Suggested change
"chrome": {
"version_added": false,
"notes": "Chrome 105 to Chrome 118 (inclusive) supported this interface name with a significantly different specification."
},
"chrome": [
{
"version_added": "200"
},
{
"version_added": "105",
"version_added": "119",
"notes": "Chrome 105 to Chrome 118 (inclusive) supported this interface name with a significantly different specification."
}
],

@hamishwillee hamishwillee May 9, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Elchi3 I was expecting:

Suggested change
"chrome": {
"version_added": false,
"notes": "Chrome 105 to Chrome 118 (inclusive) supported this interface name with a significantly different specification."
},
"chrome": {
"version_added": "200",
"notes": "Chrome 105 to Chrome 118 (inclusive) supported this interface name with a significantly different specification."
},

... and one day perhaps the note disappears.

The alternative is to add this now like:

            {
              "version_added": "105",
              "version_added": "119",
              "notes": "This support had a significantly different specification."
            }

But only for the things that are supported now - i.e. not try and add in the methods that have been removed because that is what would make this very messy.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My rationale for adding a note was that some folks may expect to find this historical context in BCD.

Indeed the alternative would be to have a (partial!?) support statement with version_added: 105 and version_removed 119`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really just requires a decision. I'm happy with this.

@hamishwillee
hamishwillee requested review from Elchi3 and caugner May 9, 2025 01:21

@Elchi3 Elchi3 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I would say let's go with how it is now then. We can always introduce ranged versions for Chrome if there is demand for it.

@hamishwillee

Copy link
Copy Markdown
Contributor

Thank you both. As you say, we can adjust as needed.

@hamishwillee
hamishwillee merged commit 113ad71 into mdn:main May 13, 2025
@mdn-bot mdn-bot mentioned this pull request May 13, 2025
@evilpie

evilpie commented May 13, 2025

Copy link
Copy Markdown
Contributor

I think we should also document the new sanitizer options that can now be passed to setHTMLUnsafe and parseHTMLUnsafe. Additionally setHTML on ShadowRoot is missing.

@hamishwillee

hamishwillee commented May 13, 2025 •

Copy link
Copy Markdown
Contributor

I think we should also document the new sanitizer options that can now be passed to setHTMLUnsafe and parseHTMLUnsafe. Additionally setHTML on ShadowRoot is missing.

@evilpie None of those are supported in FF138/9, which is what this was for. I understand the new features come in FF140, which I expect to look at in a few weeks. I can't do them now, because the preview release is 139.

Which is to say "I would like to". I'm going to document them even though they are not supported anywhere yet - because it is too hard to explain the API concepts without them.

@evilpie

evilpie commented May 14, 2025

Copy link
Copy Markdown
Contributor

Oh sorry, I hadn't really thought about how those aren't part of 139 yet.

@hamishwillee

Copy link
Copy Markdown
Contributor

No worries. Good you're on top of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data:api Compatibility data for Web API features. https://developer.mozilla.org/docs/Web/API size:l Pull request changing 101-1,000 lines of code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants