-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[GHS] Disallowed attribute is preserved after calling setData()
twice if RegExp contains global search flag
#10282
Comments
I suspect that the flag |
The problem seems to come from the fact we have a stateful regular expression object, which is not reset after every match. One approach is to reset it manually, using I tried both solutions and for the safety benchmarked Small test - 16K characters of an input
Large test - 160K characters of an input
As we can see, the difference seems to be negligible. |
While testing the fix, I found that the current behavior of StyleProcessor might not be correct. This makes few tests fail, as the new code corrects the bug, where previously it was ignored and returning a false positive match. With Matcher trying to match
the match never succeeds. Reducer assumes that we need all 3 values of the border to return a shorthand, e.g. Do we want to fix that now or should I just modify the tests for the time being and create a follow-up? |
In the end, I marked the problematic test as skipped, as it brings no value with the current, incorrect behavior of style reducers. |
Fix (engine): Fixed the `Matcher` handling global flag in `RegExp`s patterns. Closes #10282. Internal (paste-from-office): The usages of `Matcher` have been fixed. MINOR BREAKING CHANGE: The `Matcher` is more strict in handling `Element`s provided to the `match()` and `matchAll()` methods. It won't accept other `Node`s now.
📝 Provide detailed reproduction steps (if any)
editor.setData( '<iframe srcdoc="<strong>bar</strong>"></iframe>' );
x2.✔️ Expected result
The
<iframe>
appears withoutsrcdoc
attribute.❌ Actual result
📃 Other details
The issue occurs only if there's a
g
flag in the RegExp.If you'd like to see this fixed sooner, add a 👍 reaction to this post.
The text was updated successfully, but these errors were encountered: