Defaults for boolean SanitizerConfig items#254
Conversation
There was a problem hiding this comment.
I think this approach has some issues:
- If boolean fields have a default it should be false, not true.
- This is strictly less safe.
I think keeping them optional and using that third state to pick a default depending on which method you chose as I suggested in the issue is still a reasonable way forward.
If everyone really wants this behavior we'd have to name them removeComments and removeDataAttributes I think, defaulting to false.
|
I was also under the impression that we would make comments & data attributes allowable but not enabled in the I think we only discussed a webidl-semantics question on our call on Wednesday, so me skipping this may have contributed to that confusion? I think we wanted {} to be an "empty sanitizer" but the default to be "a securely configured sanitizer". Is that part of this change? |
|
I seem to recall a quite explicit discussion about a [Edit: Using real comment syntax now. :) ] /* 1*/ new Sanitizer().get().comments; // false
/* 2*/ new Sanitizer({}).get().comments; // false
/* 3*/ new Sanitizer({comments: true}).get().comments; // true
/* 4*/ new Sanitizer({comments: false}).get().comments; // false
/* 5*/ div.setHTMLUnsafe("<!--bla-->"); // <div></div>
/* 6*/ div.setHTMLUnsafe("<!--bla-->",{sanitizer: {}}); // <div></div>
/* 7*/ div.setHTMLUnsafe("<!--bla-->",{sanitizer:{comments:true}}); // <div><!--bla--></div>
/* 8*/ div.setHTMLUnsafe("<!--bla-->",{sanitizer:{comments:false}}); // <div></div>
/* 9*/ div.setHTML("<!--bla-->"); // <div></div>
/*10*/ div.setHTML("<!--bla-->",{sanitizer: {}}); // <div></div>
/*11*/ div.setHTML("<!--bla-->",{sanitizer:{comments:true}}); // <div><!--bla--></div>
/*12*/ div.setHTML("<!--bla-->",{sanitizer:{comments:false}}); // <div></div>I take it:
I'm trying to reconcile these. I'm guessing the explicit ones (3+4, 7+8, 11+12) are all uncontroversial. The rub is that Maybe I'm overlooking something. I think there's other ways to fix this, too, e.g. not defaulting to |
|
Nit: you want I think your analysis is correct. I tend to think it's okay for As such I think This gives these results:
(This can only happen when you pass a |
|
Okay, that makes sense.
This seems contradictory, but I think it's just about notation. I take
Oh, yes. I'll fix that... :) |
|
Oh yes. I keep inverting them. Hopefully that's just a me problem. |
|
Ha, good catch. I was also thinking "comments" meaning "allow comments". Interesting that even ourselves can get confused 😬 |
|
I change the PR to follows the discussion here. The default now depends on safe/unsafe usage. |
annevk
left a comment
There was a problem hiding this comment.
Thanks!
(This PR made me think that maybe we should improve Infra so it's easier to retrieve a map member value and default to some other value if the member doesn't exist.)
Co-authored-by: Anne van Kesteren <annevk@annevk.nl>
|
✅ 😉 |
|
What does this do: div.setHTMLUnsafe("<div data-foo='bar'>", {sanitizer:{dataAttributes:false}});I had expected |
|
I agree that's problematic. In general I wonder if this logic is correct. I would have expected us to first check the safelists if those are given. So when you iterate through the attributes:
|
This tracks development of the spec: WICG/sanitizer-api#254 The PR makes the default for "comments:" and "dataAttributes:" keys in the configuration depend on whether this is for safe or unsafe use. That requires a bit of plumbing, since now the logic to interpret a config depends on a new flag. Also adds test cases. Bug: 356601280 Change-Id: I076c5418006b0dc35babbffd7d991e04c0f1d522 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6189121 Commit-Queue: Daniel Vogelheim <vogelheim@chromium.org> Reviewed-by: Yifan Luo <lyf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1415510}
This tracks development of the spec: WICG/sanitizer-api#254 The PR makes the default for "comments:" and "dataAttributes:" keys in the configuration depend on whether this is for safe or unsafe use. That requires a bit of plumbing, since now the logic to interpret a config depends on a new flag. Also adds test cases. Bug: 356601280 Change-Id: I076c5418006b0dc35babbffd7d991e04c0f1d522 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6189121 Commit-Queue: Daniel Vogelheim <vogelheim@chromium.org> Reviewed-by: Yifan Luo <lyf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1415510}
This tracks development of the spec: WICG/sanitizer-api#254 The PR makes the default for "comments:" and "dataAttributes:" keys in the configuration depend on whether this is for safe or unsafe use. That requires a bit of plumbing, since now the logic to interpret a config depends on a new flag. Also adds test cases. Bug: 356601280 Change-Id: I076c5418006b0dc35babbffd7d991e04c0f1d522 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6189121 Commit-Queue: Daniel Vogelheim <vogelheim@chromium.org> Reviewed-by: Yifan Luo <lyf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1415510}
|
Here's a WPT test that mirrors the proposals here, with allowance for inverting the booleans :). It also assumes that |
|
Okay, maybe this doesn't make sense, but if we made |
Fwiw, I also thought that. Should the name be clearer? I like short names, but I slightly wonder if we are talking about something critical like - maybe its worth some extra characters? |
I think the dictionary already provides this explicit nullability, by not having the key present at all. I.e., An observable difference would be something like, |
Per the current proposal(s), |
…for comments and data-*., a=testonly Automatic update from web-platform-tests [Sanitizer API] Update default handling for comments and data-*. This tracks development of the spec: WICG/sanitizer-api#254 The PR makes the default for "comments:" and "dataAttributes:" keys in the configuration depend on whether this is for safe or unsafe use. That requires a bit of plumbing, since now the logic to interpret a config depends on a new flag. Also adds test cases. Bug: 356601280 Change-Id: I076c5418006b0dc35babbffd7d991e04c0f1d522 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6189121 Commit-Queue: Daniel Vogelheim <vogelheim@chromium.org> Reviewed-by: Yifan Luo <lyf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1415510} -- wpt-commits: 07920967d79b3c88d440ddede3f7f5dc3b81c573 wpt-pr: 50486
SHA: 87f1c88 Reason: push, by otherdaniel Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…n (default) config. r=emilio This implements: WICG/sanitizer-api#254 WICG/sanitizer-api#284 Differential Revision: https://phabricator.services.mozilla.com/D245067
…n (default) config. r=emilio This implements: WICG/sanitizer-api#254 WICG/sanitizer-api#284 Differential Revision: https://phabricator.services.mozilla.com/D245067 UltraBlame original commit: 7ec7c8891adce7e8ea2116027cc23f30caa566a8
…n (default) config. r=emilio This implements: WICG/sanitizer-api#254 WICG/sanitizer-api#284 Differential Revision: https://phabricator.services.mozilla.com/D245067 UltraBlame original commit: 7ec7c8891adce7e8ea2116027cc23f30caa566a8
…n (default) config. r=emilio This implements: WICG/sanitizer-api#254 WICG/sanitizer-api#284 Differential Revision: https://phabricator.services.mozilla.com/D245067 UltraBlame original commit: 7ec7c8891adce7e8ea2116027cc23f30caa566a8
…n (default) config. r=emilio This implements: WICG/sanitizer-api#254 WICG/sanitizer-api#284 Differential Revision: https://phabricator.services.mozilla.com/D245067
…for comments and data-*., a=testonly Automatic update from web-platform-tests [Sanitizer API] Update default handling for comments and data-*. This tracks development of the spec: WICG/sanitizer-api#254 The PR makes the default for "comments:" and "dataAttributes:" keys in the configuration depend on whether this is for safe or unsafe use. That requires a bit of plumbing, since now the logic to interpret a config depends on a new flag. Also adds test cases. Bug: 356601280 Change-Id: I076c5418006b0dc35babbffd7d991e04c0f1d522 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6189121 Commit-Queue: Daniel Vogelheim <vogelheim@chromium.org> Reviewed-by: Yifan Luo <lyf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1415510} -- wpt-commits: 07920967d79b3c88d440ddede3f7f5dc3b81c573 wpt-pr: 50486
…n (default) config. r=emilio This implements: WICG/sanitizer-api#254 WICG/sanitizer-api#284 Differential Revision: https://phabricator.services.mozilla.com/D245067
Give explicit defaults to SanitizerConfig.comments and SanitizerConfig.dataAttributes.
This fixes one of the issues in #249.
Preview | Diff