Skip to content

Commit 588c484

Browse files
committed
fix: limit match length of email regular expression
closes #8
1 parent 65d8ac2 commit 588c484

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,13 @@ function transformGfmAutolinkLiterals(tree) {
141141
tree,
142142
[
143143
[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi, findUrl],
144-
[/([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/g, findEmail]
144+
// Use {1,1024} instead of `+` to avoid pathological regular expression
145+
// behavior; see
146+
// https://github.com/syntax-tree/mdast-util-gfm-autolink-literal/issues/8
147+
[
148+
/([-.\w+]{1,1024})@([-\w]{1,1024}(?:\.[-\w]{1,1024}){1,1024})/g,
149+
findEmail
150+
]
145151
],
146152
{ignore: ['link', 'linkReference']}
147153
)

0 commit comments

Comments
 (0)