You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
The regular expression catchSlateFragment matches /data-slate-fragment="(.+?)"/ anywhere in pasted HTML, including in text nodes. This casues an error if the capture group isn't a properly formatted Slate fragment. The error doesn't crash the editor, but it does prevent pasting.
In Browser A, type data-slate-fragment="[any text here]"
Copy all text
Paste into Browser B
Paste fails, error in console
In the case of Safari, pasting into the same editor also causes the error, since we cannot rely on application/x-slate-fragment (see #4998).
Expectation
We should ensure that data-slate-fragment is only parsed in the attributes of a HTML tag, not in text nodes. If fully parsing the HTML isn't an option, the following regular expression should suffice, so long as < tags are properly encoded in text nodes (which they should be).
/<[^>]+data-slate-fragment="(.+?)"/
Environment
Slate Version: 0.91.7
Operating System: macOS
Browser: Safari, (Chrome and Firefox when pasting between browsers)
The text was updated successfully, but these errors were encountered:
Description
The regular expression
catchSlateFragment
matches/data-slate-fragment="(.+?)"/
anywhere in pasted HTML, including in text nodes. This casues an error if the capture group isn't a properly formatted Slate fragment. The error doesn't crash the editor, but it does prevent pasting.Recording
https://user-images.githubusercontent.com/4272090/222422917-00f36461-3fe2-47a0-8dc7-77ee2594652e.mp4
Sandbox
https://www.slatejs.org/examples/richtext
Steps
To reproduce the behavior:
data-slate-fragment="[any text here]"
In the case of Safari, pasting into the same editor also causes the error, since we cannot rely on
application/x-slate-fragment
(see #4998).Expectation
We should ensure that
data-slate-fragment
is only parsed in the attributes of a HTML tag, not in text nodes. If fully parsing the HTML isn't an option, the following regular expression should suffice, so long as<
tags are properly encoded in text nodes (which they should be).Environment
The text was updated successfully, but these errors were encountered: