-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Fix GFM tables not breaking on block-level structures #1598
Conversation
Includes test cases for all block-level structures and some inline-level structures (which should still appear in the table)
This pull request is being automatically deployed with ZEIT Now (learn more). |
Deployment failed with the following error:
|
Deployment failed with the following error:
|
If it helps, the only change was in the detection of table cells (the third captured regex group) where I replaced
with
and then apply the helper.js "edit" function in identical manner to the paragraph breaking logic earlier in the document. Note that this new bit of code does not apply repetition (“+”, “*”) to a complex subexpression Given that, if the paragraph code has been deemed safe from REDOS attacks there shouldn't be anything different here except that I also include regex for |
</tr> | ||
</tbody> | ||
</table> | ||
<h1 id="title">title</h1> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm.... The spec says "The table is broken at the first empty line, or beginning of another block-level structure", so that would seem to break their rule, as the setext headings fall under the "Leaf Block" category.
At that point do you follow the spec, or do you follow GitHub's implementation of the spec? Either way, it's a simple change of just removing the associated lines that check for lheading
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, your test seems correct. I also double checked to make sure our GFM spec tests included 201 [extension] Tables
and it is passing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from the spec:
In general, a setext heading need not be preceded or followed by a blank line. However, it cannot interrupt a paragraph, so when a setext heading comes after a paragraph, a blank line is needed between them.
Maybe since it cannot interrupt a paragraph it also shouldn't interrupt a table? I'm leaning toward following the implementation and posing this as an issue to GitHub to see what they have to say. github/cmark-gfm#179
We could leave the regex in and just comment it out with a note so we can change it easily in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, thanks! 🎉
Is this stable enough for me to look at the regexes for ReDoS?
…On Mon, Feb 10, 2020, 9:55 AM Steven ***@***.***> wrote:
***@***.**** approved this pull request.
Great work, thanks! 🎉
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1598?email_source=notifications&email_token=AFOD3LZYGJC6B5QRUFGPGOTRCFTFVA5CNFSM4KQEZVZKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCU4CAUY#pullrequestreview-355999827>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFOD3L4NI62KB5O6GNMSMDDRCFTFVANCNFSM4KQEZVZA>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few edits to make the regex faster and less susceptible to a redos attack.
@davisjam yes that would be great. I kind of looked it over but I'm sure you are better at finding them. |
Simplify `code` regex Co-Authored-By: Tony Brix <[email protected]>
Unneeded + on regex heading detection after tables and paragraphs
Fences after tables fixed in line with PR markedjs#1600.
Has there been any progress on this step? Is there anything I can help with? |
@davisjam have you had time to look at these? |
Marked version: 8.0
Markdown flavor: GitHub Flavored Markdown
Description
What was attempted
Edited rules.js to break GFM tables properly using similar syntax used to break paragraphs.
Contributor
Committer
In most cases, this should be a different person than the contributor.