Significant general performance optimizations in some cases#599
Significant general performance optimizations in some cases#599cure53 merged 6 commits intocure53:mainfrom GrantGryczan:main
Conversation
There was a problem hiding this comment.
I need your confirmation on the last commit:
I think it would be better to have it always call importNode if RETURN_DOM_IMPORT is set to true, so that it works as expected when set explicitly, but have it default to false when shadowroot is not in the ALLOWED_ATTR attribute, rather than overriding it and preventing importNode from getting called even when RETURN_DOM_IMPORT is true. Does that sound appropriate?
If so, some tests will need to be changed in consideration of this change, but I can probably do that.
|
Alright, let's run some tests :) |
|
It's not ready yet; this is still a draft. See my previous comment above |
|
Oh, sorry, no worries.
So, the goal of whatever we do here is to avoid having people configure themselves to be prone to XSS when they are not aware of it. No matter how we do it, this needs to be prio number one. |
In that case, perhaps it would be better to discard the |
|
Hmmm, not sure how many people already use it. And not sure how many of those allow |
|
Of the people who are using it, there are two possible cases:
Thus, I don't see any issue with removing it. |
|
I think you are right, let's nuke it. |
|
Oh! I realize the reason it's likely there despite your concern about users unwittingly opening themselves to vulnerability. It's useful if all of the following conditions are true for your use case:
I still don't think it's worth keeping though, because it's a minor non-security benefit (a performance improvement for very large node trees) and only in very rare conditions ( But it's up to you; you know about web security and DOMPurify's goals better than I do. Let me know what you think. |
|
Let's remove it for now and see if people complain. Less complexity is better in the long run. |
|
Alright, all ready now. I've changed up a couple of the tests which used to pertain to DOM importing. Needless to say, review my changes to the tests especially carefully. I tried to ensure that my changes kept the purpose of each test--what possible issue each test was trying to prevent--the same. |
|
Looks like there are merge conflicts now that you've accepted a PR from someone else and made some changes of your own in the meantime. I hope it's easier for you to take care of that from your end. If not, then I'm not sure how to handle it from my end, and I may need some help. |
|
There should be nothing that conflicts with your changes afaics, just generated stuff |
|
Alright, conflicts resolved, let's see what the tests say! |
|
This looks great, thank you very much 🙇 😄 |
Resolves #584
Resolves #585
Incidentally, this also ensures
importNodeis only called on the output when necessary, rather than letting users configure it withRETURN_DOM_IMPORT, possibly opening themselves up to vulnerabilities. (See discussion below.)