Skip to content

Commit 168713f

Browse files
progfayprogfay
authored and
progfay
committed
Merge pull request #540 from progfay/fix-link-ReDoS
Fix(ExternalLinkNode): fix Inefficient regular expression
1 parent e857502 commit 168713f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/block/node/ExternalLinkNode.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { createNodeParser } from './creator'
33
import type { LinkNode } from './type'
44
import type { NodeCreator } from './creator'
55

6-
const hrefFirstUrlRegExp = /\[https?:\/\/[^\s\]]+(?:\s+[^\]]*[^\s])?\]/
7-
const contentFirstUrlRegExp = /\[[^\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/
8-
const httpRegExp = /(?<=^| )https?:\/\/[^\s\]]+/
6+
const hrefFirstUrlRegExp = /\[https?:\/\/[^\s\]]+(?:\s+[^[\]]*[^\s])?\]/
7+
const contentFirstUrlRegExp = /\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/
8+
const httpRegExp = /(?<=^| )https?:\/\/[^[\s\]]+/
99

1010
const createExternalLinkNode: NodeCreator<LinkNode> = target => {
1111
if (target.startsWith('[') && target.endsWith(']')) {

0 commit comments

Comments
 (0)