Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/markup/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ var (
// well as the HTML5 spec:
// http://spec.commonmark.org/0.28/#email-address
// https://html.spec.whatwg.org/multipage/input.html#e-mail-state-(type%3Demail)
emailRegex = regexp.MustCompile("(?:\\s|^|\\(|\\[)([a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9]{2,}(?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+)(?:\\s|$|\\)|\\]|\\.(\\s|$))")
emailRegex = regexp.MustCompile("(?:\\s|^|\\(|\\[)([a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9]{2,}(?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+)(?:\\s|$|\\)|\\]|;|,|\\?|!|\\.(\\s|$))")

// blackfriday extensions create IDs like fn:user-content-footnote
blackfridayExtRegex = regexp.MustCompile(`[^:]*:user-content-`)
Expand Down
12 changes: 12 additions & 0 deletions modules/markup/html_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,18 @@ func TestRender_email(t *testing.T) {
"send email to [email protected].",
`<p>send email to <a href="mailto:[email protected]" rel="nofollow">[email protected]</a>.</p>`)

test(
`[email protected],
[email protected].
[email protected];
[email protected]?
[email protected]!`,
`<p><a href="mailto:[email protected]" rel="nofollow">[email protected]</a>,<br/>
<a href="mailto:[email protected]" rel="nofollow">[email protected]</a>.<br/>
<a href="mailto:[email protected]" rel="nofollow">[email protected]</a>;<br/>
<a href="mailto:[email protected]" rel="nofollow">[email protected]</a>?<br/>
<a href="mailto:[email protected]" rel="nofollow">[email protected]</a>!</p>`)

// Test that should *not* be turned into email links
test(
"\"[email protected]\"",
Expand Down