Skip to content

Fix <em> issue with mixed content #1410 - #1451

Merged
styfle merged 11 commits into
masterfrom
unknown repository
May 22, 2019
Merged

Fix <em> issue with mixed content #1410#1451
styfle merged 11 commits into
masterfrom
unknown repository

Conversation

@ghost

@ghostghost commented Mar 18, 2019

Copy link
Copy Markdown

Marked version:

Markdown flavor: Markdown.pl|CommonMark|GitHub Flavored Markdown|n/a

Description

It was caused _ and * parsed being differently in the em regex. I just replaced the part that searches for *test* and replaced it with the part searches for _test_ and then just charged the characters. I don't know why they were different. Maybe there's a reason for it. All the tests pass, so I dunno.

Contributor

  • Test(s) exist to ensure functionality and minimize regression

Committer

In most cases, this should be a different person than the contributor.

  • Draft GitHub release notes have been updated.
  • CI is green (no forced merge required).
  • Merge PR

@ghost

Copy link
Copy Markdown
Author

ran wrong test command

@ghost

ghost commented Mar 18, 2019

Copy link
Copy Markdown
Author

Wait, is it expecting a bug to be there? If it is, I seemed to have fixed it.

@UziTech

Copy link
Copy Markdown
Member

Ya the spec tests that are currently failing will fail if they start passing. You will need to remove shouldFail: true from /test/specs/commonmark/commonmark.0.28.json line #3730

It looks like you are also failing some tests that used to pass.

@UziTech

Copy link
Copy Markdown
Member

The shouldFail lets us know which tests are fixed by each PR and let us keep track of the spec tests that we need to work on.

@ghost

Copy link
Copy Markdown
Author

ok I figured out why they are different. It was to prevent it from being interpreted as an ordered List.

Also the underscore group has a bug: https://marked.js.org/demo/?text=_%3Cimg%20src%3D%22https%3A%2F%2Fwww.google.com%2Ffavicon.ico%22%20title%3D%22*_%22%2F%3E%0A%0A*%3Cimg%20src%3D%22https%3A%2F%2Fwww.google.com%2Ffavicon.ico%22%20title%3D%22*%22%2F%3E&options=&version=master

The asterisk was processed correctly. While the underscore was not. So the bug was transferred over.

So the underscore and asterisk groups need to be rewritten.

@ghost

Copy link
Copy Markdown
Author

Ok I think, I fixed it this time.

Comment threadlib/marked.js Outdated
@UziTech

Copy link
Copy Markdown
Member

@davisjam could you check if these regexps are secure from redos?

Here are the new and old derived regexps for em:

New:

/^_([^\s_])_(?!_)|^\*([^\s*<\[])\*(?!\*)|^_([^\s<][\s\S]*?[^\s_])_(?!_|[^\s!"#$%&'()*+,\-.\/:;<=>?@\[^_{|}~])|^_([^\s_<][\s\S]*?[^\s])_(?!_|[^\s!"#$%&'()*+,\-.\/:;<=>?@\[^_{|}~])|^\*([^\s<"][\s\S]*?[^\s\*])\*(?!\*|[^\s!"#$%&'()*+,\-.\/:;<=>?@\[^_{|}~])|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/

Old:

/^_([^\s_])_(?!_)|^\*([^\s*"<\[])\*(?!\*)|^_([^\s][\s\S]*?[^\s_])_(?!_|[^\s!"#$%&'()*+,\-.\/:;<=>?@\[^_{|}~])|^_([^\s_][\s\S]*?[^\s])_(?!_|[^\s!"#$%&'()*+,\-.\/:;<=>?@\[^_{|}~])|^\*([^\s"<\[][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/

@UziTech
UziTech requested a review from davisjamMarch 21, 2019 18:42
@UziTech

Copy link
Copy Markdown
Member

@x13machine could you rebase this so we could get it merged?

@ghost

Copy link
Copy Markdown
Author

Ok I'll do that today

@ghost

ghost commented May 21, 2019

Copy link
Copy Markdown
Author

How do I fix the errors? 😕

@UziTech

Copy link
Copy Markdown
Member

looks like example 455 should be "shouldFail": true and the "shouldFail" line should be removed on example 418 and 477

Also move the new test files to /test/specs/new/

Comment threadtest/new/em_list_links.html
Comment threadtest/new/em_list_links.md
@UziTech

Copy link
Copy Markdown
Member

I'm not sure why the latest commit didn't trigger travis to run the tests, but I ran it locally and everything passed.

@UziTech
UziTech requested review from joshbruce and styfleMay 22, 2019 17:52
@UziTech

Copy link
Copy Markdown
Member

This still doesn't fix *[link*](url* but that can be a separate PR.

marked demo
commonmark demo

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@UziTech@styfle@203x