Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nschloe opened this issue Oct 30, 2023 · 7 comments
Open

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

nschloe opened this issue Oct 30, 2023 · 7 comments
Assignees
Labels

Comments

@nschloe
Copy link

nschloe commented Oct 30, 2023

Description

Related to #27616.

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

However, Gitea renders them as such:

screenshot_2023-10-30-202802

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

?[email protected]
~[email protected]
*[email protected]
~[email protected]

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

@dek5troza
Copy link

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

@lng2020
Copy link
Member

lng2020 commented 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.

@dek5troza
Copy link

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

dek5troza added a commit to dek5troza/gitea that referenced this issue Nov 22, 2023
Valid email addresses should start with alphanumeric character.
@dek5troza
Copy link

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 added a commit to dek5troza/gitea that referenced this issue Nov 23, 2023
Regular expression will attempt to match valid portion of the email
which start with ~,* or ? or their combination.
@wxiaoguang
Copy link
Contributor

wxiaoguang commented Nov 28, 2023

FYI: actually [email protected] and *[email protected] are valid email addresses ....... so it's hard to say "GitHub is right" .....

func main() {
	a, _ := mail.ParseAddress("[email protected]")
	println(a.Address)
	a, _ = mail.ParseAddress("*[email protected]")
	println(a.Address)
}

Output:
[email protected]
*[email protected]

@lng2020
Copy link
Member

lng2020 commented Nov 28, 2023

According to https://stackoverflow.com/questions/201323/how-can-i-validate-an-email-address-using-a-regular-expression, [email protected] and *[email protected] 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

@wxiaoguang
Copy link
Contributor

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.

@nschloe nschloe changed the title Rendering: Email addresses don't start with a special char Rendering: Email addresses don't start with a special char (do they?) Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants