-
-
Notifications
You must be signed in to change notification settings - Fork 748
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
Can't sanitize some DOM snippets, e.g. <td>text</td> #190
Comments
That is because certain elements cannot stand on their own, particularly table data elements. They need a parent element to be able to function and make sense. The browser throws away elements that cannot stand on their own - and we use the browser to sanitize :) This cannot easily be fixed in the core but a fix should be easy to implement via hook. Basically check upon element sanitation if it's a table data and react accordingly. Would that work for you? |
Only if you parse the string as an entire document using DOMParser. Other techniques such as jQuery.parseHTML will give you a single table node form |
Indeed. But Being able to throw in DOM nodes and get a sanitized node back is indeed an interesting feature and we might implement that at some point. But not anytime soon - so in the meantime I recommend to use a hook to fix this problem. |
FYI our use case is Wikipedia's visual editor, where we'd like to be able to pass around user-generated transactions that may include generated HTML fragments. In normal usage these fragments are safe, but there's nothing to stop someone injecting malicious HTML via the client side APIs. |
input:
<td>text</td>
expected:
<td>text</td>
actual:
text
The text was updated successfully, but these errors were encountered: