-
-
Notifications
You must be signed in to change notification settings - Fork 556
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
Quadratic behavior when parsing smart quotes #521
Comments
I think removing delims between the quotes makes sense (not sure why I didn't do that originally?). |
Here's an example how removing delimiters between quotes changes parsing results: Before:
After (the underscore between quotes will be ignored):
I also noticed that smart quotes are always converted even if no matching pair is found. |
I guess the question is whether we want to treat smart quotes as at the same precedence level as Since it's an extension, this isn't decided one way or the other by the spec. I suppose one could argue that spec'd behavior should take precedence, so that smart quotes should have a lower precedence level. Not sure how strong that is. In any case, these are corner cases; it's hard to imagine this would affect anything serious. |
Other than the commonmark-hs smart quotes extension, most implementations don't do that.
|
Reproduce with:
After unquoting, this input looks like
This also works with emphasis:
When matching a pair of smart quotes, we currently don't remove delimiters (emphasis or other smart quotes) between the quotes. This can lead to quadratic behavior when processing deeply nested quotes interspersed with emphasis or different quotes.
A simple way to fix this issue is to delete delimiters between smart quotes but this changes the parsing rules. Another, more complicated approach is to handle single quotes, double quotes and emphasis in separate lists.
This is the only remaining issue with quadratic complexity in the parser that I could find with a specialized fuzzer similar to the "quadratic" fuzzers in cmark-gfm. Note that there are still some issues in the serializers.
The text was updated successfully, but these errors were encountered: