Skip to content

Commit 08d2512

Browse files
authored
Merge pull request #977 from KostyaTretyak/parser-fix
Parser fix
2 parents 6657cec + 13e97eb commit 08d2512

File tree

4 files changed

+36
-13
lines changed

4 files changed

+36
-13
lines changed

lib/marked.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,9 @@ Lexer.prototype.token = function(src, top, bq) {
445445

446446
var inline = {
447447
escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
448-
autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
448+
autolink: /^<([^ <>]+(@|:\/)[^ <>]+)>/,
449449
url: noop,
450-
tag: /^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,
450+
tag: /^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^<'">])*?>/,
451451
link: /^!?\[(inside)\]\(href\)/,
452452
reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
453453
nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,

test/tests/auto_links.html

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
<p>Link: <a href="http://example.com/">http://example.com/</a>.</p>
22

3-
<p>With an ampersand: <a href="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</a></p>
3+
<p>With an ampersand: <a href="http://example1.com/?foo=1&amp;bar=2">http://example1.com/?foo=1&amp;bar=2</a></p>
44

55
<ul>
66
<li>In a list?</li>
7-
<li><a href="http://example.com/">http://example.com/</a></li>
7+
<li><a href="http://example2.com/">http://example2.com/</a></li>
88
<li>It should.</li>
99
</ul>
1010

1111
<blockquote>
12-
<p>Blockquoted: <a href="http://example.com/">http://example.com/</a></p>
12+
<p>Blockquoted: <a href="http://example3.com/">http://example3.com/</a></p>
1313
</blockquote>
1414

15-
<p>Auto-links should not occur here: <code>&lt;http://example.com/&gt;</code></p>
15+
<p>Auto-links should not occur here: <code>&lt;http://example4.com/&gt;</code></p>
1616

17-
<pre><code>or here: &lt;http://example.com/&gt;
17+
<pre><code>or here: &lt;http://example5.com/&gt;
1818
</code></pre>
19+
20+
<p>Open angle bracket with link:</p>
21+
22+
<p>&lt;<a href="http://example6.com">http://example6.com</a></p>
23+
24+
<p>With space: &lt; <a href="http://example7.com">http://example7.com</a></p>
25+
26+
<p>With content: &lt;1 <a href="http://example8.com">http://example8.com</a></p>
27+
28+
<p>hello world
29+
<a href="http://example9.com">http://example9.com</a>
30+
</p>

test/tests/auto_links.text

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
Link: <http://example.com/>.
22

3-
With an ampersand: <http://example.com/?foo=1&bar=2>
3+
With an ampersand: <http://example1.com/?foo=1&bar=2>
44

55
* In a list?
6-
* <http://example.com/>
6+
* <http://example2.com/>
77
* It should.
88

9-
> Blockquoted: <http://example.com/>
9+
> Blockquoted: <http://example3.com/>
1010

11-
Auto-links should not occur here: `<http://example.com/>`
11+
Auto-links should not occur here: `<http://example4.com/>`
1212

13-
or here: <http://example.com/>
13+
or here: <http://example5.com/>
14+
15+
Open angle bracket with link:
16+
17+
<<http://example6.com>
18+
19+
With space: < <http://example7.com>
20+
21+
With content: <1 <http://example8.com>
22+
23+
hello world
24+
<http://example9.com>
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<p><a href="mailto:&lt;svg/onload=&quot;alert(1)&quot;//@x">&lt;svg/onload=&quot;alert(1)&quot;//@x</a></p>
1+
<p>&lt;<a href="mailto:svg/onload=&quot;alert(1)&quot;//@x">svg/onload=&quot;alert(1)&quot;//@x</a></p>
22

33
<p><a href="mailto:bar&quot;onclick=&quot;alert(&#39;XSS&#39;)&quot;@foo">bar&quot;onclick=&quot;alert(&#39;XSS&#39;)&quot;@foo</a></p>

0 commit comments

Comments
 (0)