fix: fix link url with no closing parenthesis (#3664)
* fix: fix link url with no closing parenthesis * add escape test * add double escape
This commit is contained in:
parent
d5e5f8fbbc
commit
72b63739f4
@ -636,6 +636,11 @@ export class _Tokenizer {
|
||||
} else {
|
||||
// find closing parenthesis
|
||||
const lastParenIndex = findClosingBracket(cap[2], '()');
|
||||
if (lastParenIndex === -2) {
|
||||
// more open parens than closed
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastParenIndex > -1) {
|
||||
const start = cap[0].indexOf('!') === 0 ? 5 : 4;
|
||||
const linkLen = start + cap[1].length + lastParenIndex;
|
||||
|
@ -141,5 +141,9 @@ export function findClosingBracket(str: string, b: string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (level > 0) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -3975,8 +3975,7 @@
|
||||
"example": 497,
|
||||
"start_line": 7666,
|
||||
"end_line": 7670,
|
||||
"section": "Links",
|
||||
"shouldFail": true
|
||||
"section": "Links"
|
||||
},
|
||||
{
|
||||
"markdown": "[link](foo\\(and\\(bar\\))\n",
|
||||
|
@ -3975,8 +3975,7 @@
|
||||
"example": 497,
|
||||
"start_line": 7666,
|
||||
"end_line": 7670,
|
||||
"section": "Links",
|
||||
"shouldFail": true
|
||||
"section": "Links"
|
||||
},
|
||||
{
|
||||
"markdown": "[link](foo\\(and\\(bar\\))\n",
|
||||
|
7
test/specs/new/link_unbalanced.html
Normal file
7
test/specs/new/link_unbalanced.html
Normal file
@ -0,0 +1,7 @@
|
||||
<p>[link](foo(bar())</p>
|
||||
|
||||
<p><a href="foo(bar()">link</a></p>
|
||||
|
||||
<p><a href="foo(bar()">link</a></p>
|
||||
|
||||
<p>[link](foo(bar\())</p>
|
7
test/specs/new/link_unbalanced.md
Normal file
7
test/specs/new/link_unbalanced.md
Normal file
@ -0,0 +1,7 @@
|
||||
[link](foo(bar())
|
||||
|
||||
[link](foo\(bar())
|
||||
|
||||
[link](foo(bar\())
|
||||
|
||||
[link](foo(bar\\())
|
Loading…
x
Reference in New Issue
Block a user