diff --git a/modules/markup/html.go b/modules/markup/html.go index adc2bef53..91913b067 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -63,7 +63,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](?:[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|$))") linkRegex, _ = xurls.StrictMatchingScheme("https?://") ) diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go index 543db1d46..daf953c9e 100644 --- a/modules/markup/html_test.go +++ b/modules/markup/html_test.go @@ -176,6 +176,9 @@ func TestRender_email(t *testing.T) { test( "info@gitea.com.", `
`) + test( + "firstname+lastname@gitea.com", + ``) test( "send email to info@gitea.co.uk.", `send email to info@gitea.co.uk.
`) @@ -190,6 +193,18 @@ func TestRender_email(t *testing.T) { test( "git@try.gitea.io:go-gitea/gitea.git", `git@try.gitea.io:go-gitea/gitea.git
`) + test( + "gitea@3", + `gitea@3
`) + test( + "gitea@gmail.c", + `gitea@gmail.c
`) + test( + "email@domain@domain.com", + `email@domain@domain.com
`) + test( + "email@domain..com", + `email@domain..com
`) } func TestRender_ShortLinks(t *testing.T) {