Skip to content

Commit 95a7deb

Browse files
authored
Merge pull request #540 from progfay/fix-link-ReDoS
Fix(ExternalLinkNode): fix Inefficient regular expression
2 parents 5baf876 + 30f6293 commit 95a7deb

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> = raw => {
1111
const inner = raw.startsWith('[') && raw.endsWith(']') ? raw.substring(1, raw.length - 1) : raw

0 commit comments

Comments
 (0)