Rendering: Email addresses don't start with a special char (do they?) #11935

Closed
opened 2025-11-02 09:52:12 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @nschloe on GitHub (Oct 30, 2023).

Originally assigned to: @dek5troza on GitHub.

Description

Related to https://github.com/go-gitea/gitea/issues/27616.

Email addresses can only start with an alphanumeric character. Hence these are not valid email addresses:

?a@example.com
~a@example.com
*a@example.com
~a@example.com

However, Gitea renders them as such:

screenshot_2023-10-30-202802

The mailto link should only start at the a. GitHub handles this correctly:

?a@example.com
~a@example.com
*a@example.com
~a@example.com

Gitea Version

1.22.0+dev-262-gec0c6829d

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

https://try.gitea.io/

Database

None

Originally created by @nschloe on GitHub (Oct 30, 2023). Originally assigned to: @dek5troza on GitHub. ### Description Related to https://github.com/go-gitea/gitea/issues/27616. Email addresses can only start with an alphanumeric character. Hence these are not valid email addresses: ``` ?a@example.com ~a@example.com *a@example.com ~a@example.com ``` However, Gitea renders them as such: ![screenshot_2023-10-30-202802](https://github.com/go-gitea/gitea/assets/181628/273dc68e-fbe0-4a48-9057-84914e3021f7) The `mailto` link should only start at the `a`. GitHub handles this correctly: ?a@example.com ~a@example.com *a@example.com ~a@example.com ### Gitea Version 1.22.0+dev-262-gec0c6829d ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? https://try.gitea.io/ ### Database None
GiteaMirror added the type/bug label 2025-11-02 09:52:12 -06:00
Author
Owner

@dek5troza commented on GitHub (Nov 8, 2023):

Hi, I would offer my time to help fix this, if this is something suitable for first timer to gitea?

@dek5troza commented on GitHub (Nov 8, 2023): Hi, I would offer my time to help fix this, if this is something suitable for first timer to gitea?
Author
Owner

@lng2020 commented on GitHub (Nov 13, 2023):

Hi, I would offer my time to help fix this, if this is something suitable for first timer to gitea?

Seems like a good first issue. Changing the regexp and adding a test like this PR will probably solve the problem.

@lng2020 commented on GitHub (Nov 13, 2023): > Hi, I would offer my time to help fix this, if this is something suitable for first timer to gitea? Seems like a good first issue. Changing the regexp and adding a test like [this PR](https://github.com/go-gitea/gitea/pull/27987) will probably solve the problem.
Author
Owner

@dek5troza commented on GitHub (Nov 13, 2023):

Thanks for the pointer. I will take care of it, you can assign it to me if you want.

@dek5troza commented on GitHub (Nov 13, 2023): Thanks for the pointer. I will take care of it, you can assign it to me if you want.
Author
Owner

@dek5troza commented on GitHub (Nov 22, 2023):

Sorry for the delay. I modified the regular expression to allow emails only to start with alphanumeric character, and few test cases from the bug report, validating that these are no longer rendered as valid email addresses. Please let me know, if anything needs update, or if I have missed something, and I ll take care of it.

@dek5troza commented on GitHub (Nov 22, 2023): Sorry for the delay. I modified the regular expression to allow emails only to start with alphanumeric character, and few test cases from the bug report, validating that these are no longer rendered as valid email addresses. Please let me know, if anything needs update, or if I have missed something, and I ll take care of it.
Author
Owner

@wxiaoguang commented on GitHub (Nov 28, 2023):

FYI: actually ~a@a.com and *a@a.com are valid email addresses ....... so it's hard to say "GitHub is right" .....

func main() {
	a, _ := mail.ParseAddress("~a@b.com")
	println(a.Address)
	a, _ = mail.ParseAddress("*a@b.com")
	println(a.Address)
}

Output:
~a@b.com
*a@b.com
@wxiaoguang commented on GitHub (Nov 28, 2023): FYI: actually `~a@a.com` and `*a@a.com` are valid email addresses ....... so it's hard to say "GitHub is right" ..... ``` func main() { a, _ := mail.ParseAddress("~a@b.com") println(a.Address) a, _ = mail.ParseAddress("*a@b.com") println(a.Address) } Output: ~a@b.com *a@b.com ```
Author
Owner

@lng2020 commented on GitHub (Nov 28, 2023):

According to https://stackoverflow.com/questions/201323/how-can-i-validate-an-email-address-using-a-regular-expression, ~a@a.com and *a@a.com are valid email addresses.
But interestingly Gmail doesn't render it either. Seems like both GitHub and Gmail use more strict rules for rendering.
image

@lng2020 commented on GitHub (Nov 28, 2023): According to https://stackoverflow.com/questions/201323/how-can-i-validate-an-email-address-using-a-regular-expression, `~a@a.com` and `*a@a.com` are valid email addresses. But interestingly Gmail doesn't render it either. Seems like both GitHub and Gmail use more strict rules for rendering. ![image](https://github.com/go-gitea/gitea/assets/70063547/9e91adc7-1d76-4177-925e-30f256ac77b3)
Author
Owner

@wxiaoguang commented on GitHub (Nov 28, 2023):

I have no preference for either choice.

But if we'd like to improve it, it needs enough comments and test cases to document the behavior and how the decision was made.

@wxiaoguang commented on GitHub (Nov 28, 2023): I have no preference for either choice. But if we'd like to improve it, it needs enough comments and test cases to document the behavior and how the decision was made.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11935