Skip to content
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

Don't fail on missing code tag in code block parsing #27

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dbohn
Copy link

@dbohn dbohn commented Aug 11, 2022

When parsing an HTML input using this library, that contains a <pre>-tag without any child element like the code tag generated by TipTap itself, the parser will generate an error, as it tries to call the getAttribute method on a child node, that is of type DOMText (or even null, if the block is empty). The error occurs, while infering the language of the code block.

This might not happen, if using the tip tap editor, but it breaks the use case of the sanitize method, as it would fail and not sanitize in this case.

This PR adds a check for the type of the respective child node.

@dbohn dbohn force-pushed the fix-invalid-codeblock-parsing branch from 7ade101 to 5489beb Compare August 11, 2022 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant