Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Empty string input crashes #8

Open
noties opened this issue Feb 14, 2020 · 5 comments
Open

Empty string input crashes #8

noties opened this issue Feb 14, 2020 · 5 comments
Labels
bug Something isn't working

Comments

@noties
Copy link
Owner

noties commented Feb 14, 2020

noties/Markwon#192

@noties noties added the bug Something isn't working label Feb 14, 2020
@Meisolsson
Copy link

I'm having this issue with the following markdown file https://raw.githubusercontent.com/yahoo/gifshot/master/README.md

Is there any idea on how to solve this in Prism4j?

@noties
Copy link
Owner Author

noties commented Mar 26, 2020

Hello @Meisolsson !

At first I thought those 2 issues are unreleated. As markdown file that you'd linked does not contain empty code blocks. Then I have found out that the block that fails is:

<script src='gifshot.js'></script>

which does not make sense as it is not empty. If you change script to any other tag, then no crash happens 🤔 . It turns out that javascript grammar injects itself into html grammar to handle this specific case -> javascript code inside <script> tags. But then it is invoked with empty string (as tag does not contain any text)

@Meisolsson
Copy link

Alright, any idea how to solve it? I'm guessing that the check causing the crash is required for something else.

@noties
Copy link
Owner Author

noties commented Mar 26, 2020

The fix must be implemented in the library - Prism4j must not tokenize empty inputs

bjdupuis added a commit to bjdupuis/Prism4j that referenced this issue Jul 27, 2021
Only `matchGrammar` on non-empty strings. Also added a maven publish setup for easier publishing to maven local for testing.
@alexrintt
Copy link

The fix must be implemented in the library - Prism4j must not tokenize empty inputs

Is this fix published or we need to do some dependency workaround to include a fork?

Mine version is 2.0.0, which seems to be the latest, and it's failing for this markdown file:

https://github.com/adambard/learnxinyminutes-docs/blob/master/amd.html.markdown

(disregard the frontmatter since it's not being passed to the markown -> prism4j library).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants