-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defaults for boolean SanitizerConfig items #254
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
Give explicit defaults to SanitizerConfig.comments and SanitizerConfig.dataAttributes.
This fixes one of the issues in #249.
Preview | Diff