diff --git a/modules/markup/html.go b/modules/markup/html.go index 2b4a7076ed468..1fa791df40bf7 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -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-`) diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go index 18cc1a9133c8b..5307f718798da 100644 --- a/modules/markup/html_test.go +++ b/modules/markup/html_test.go @@ -281,15 +281,21 @@ func TestRender_email(t *testing.T) { test( "*a@example.com", `
`) + test( + "a*a@example.com", + ``) test( "~a@example.com", ``) + test( + "a~a@example.com", + ``) test( "email@domain@domain.com", `email@domain@domain.com
`) // Test that should *not* be turned into email links test( - "\"info@gitea.com\"", + `"info@gitea.com"`, `"info@gitea.com"
`) test( "/home/gitea/mailstore/info@gitea/com",