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

Handle backslash-escaped brackets in link description #996

Merged
merged 1 commit into from
Jan 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ var inline = {
text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
};

inline._inside = /(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/;
inline._inside = /(?:\[[^\]]*\]|\\[\[\]]|[^\[\]]|\](?=[^\[]*\]))*/;
inline._href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;

inline.link = replace(inline.link)
Expand Down
14 changes: 14 additions & 0 deletions test/tests/links_inline_style.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,17 @@
<p><a href="/url/has space/" title="url has space and title">URL and title</a>.</p>

<p><a href="">Empty</a>.</p>

<p>Now some links with special link text.</p>

<p><a href="http://abc.com">hello [ ok</a></p>

<p><a href="http://abc.com">hello [] with balanced brackets</a></p>

<p><a href="http://abc.com">hello! [ ] with escaped balanced brackets</a></p>

<p><a href="http://abc.com">hello \ with a backslash</a></p>

<p><a href="http://abc.com">link w/ escaped back\slash</a></p>

<p><a href="http://abc.com">link w/ back\slash\</a></p>
14 changes: 14 additions & 0 deletions test/tests/links_inline_style.text
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,17 @@ Just a [URL](/url/).
[URL and title]( /url/has space/ "url has space and title").

[Empty]().

Now some links with special link text.

[hello \[ ok](http://abc.com)

[hello [] with balanced brackets](http://abc.com)

[hello! \[ \] with escaped balanced brackets](http://abc.com)

[hello \ with a backslash](http://abc.com)

[link w/ escaped back\\slash](http://abc.com)

[link w/ back\\slash\\](http://abc.com)