mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-09 04:25:18 -05:00
Valid email addresses are rejected with The email address is invalid, entirely preventing the use of gitea
#9014
Open
opened 2025-11-02 08:25:59 -06:00 by GiteaMirror
·
24 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.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c2
v1.3.3
v1.4.0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
No Label
type/bug
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#9014
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @throwaway-2e119d4c79e4b162f4 on GitHub (May 31, 2022).
Description
Valid email addresses are rejected, preventing admin user, or any other user, creation; additionally, these same valid email addresses are rejected if a temporary one is added and attempted to fix with the valid one after the fact.
Example address that is not accepted, despite being perfectly valid under (among other standards):
Example:
Gitea Version
v1.16.8
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?
not relevant
Database
MySQL
@throwaway-2e119d4c79e4b162f4 commented on GitHub (May 31, 2022):
This issue has been raised before, and closed as
completed, but clearly, it is nothttps://github.com/go-gitea/gitea/issues/17029#event-6424074969
https://github.com/go-gitea/gitea/issues/17029#issue-994354749
https://davidcel.is/2012/09/06/stop-validating-email.html
https://medium.com/hackernoon/the-100-correct-way-to-validate-email-addresses-7c4818f24643
If you are not going to send a validation email, then do not try to validate the email address; don't reject valid email addresses you haven't validated, because you cannot know they are invalid if you haven't tested their validity by verifying they are valid...
@throwaway-2e119d4c79e4b162f4 commented on GitHub (Jun 13, 2022):
Just bumping this to ensure it was seen; github (the platform itself) marked the issue as invalid, hid it, and locked my account for two weeks as a result
@6543 commented on GitHub (Jun 13, 2022):
that's stupid agree
@lunny commented on GitHub (Jun 14, 2022):
I think yes, recent version has a more restricted limitation for email address than any RFC. For your example, both
user+mailbox@example.comandcustomer/department=shipping@example.comare valid email addresses.@wxiaoguang commented on GitHub (Jun 14, 2022):
Plus since 2012 you can use international characters above U+007F, encoded as UTF-8.
https://stackoverflow.com/questions/3844431/are-email-addresses-allowed-to-contain-non-alphanumeric-characters
(just FYI, not sure whether Gitea should support it. there could be some comments or documents about supporting or not).
@6543 commented on GitHub (Jun 14, 2022):
I wold not allow all UTF-8 but more ASCI chars like _
@lunny commented on GitHub (Jun 14, 2022):
Currently capital char is only allowed with
[0-9a-zA-Z], that why$A12345@example.com,!def!xyz%abc@example.comand_somename@example.comare not considered as valid.@42wim commented on GitHub (Jun 18, 2022):
If made a PR here : https://gitea.com/go-chi/binding/pulls/12 which uses the stdlib
net/mail(which is rfc5322 compliant) for validation@lunny commented on GitHub (Jun 18, 2022):
That function allow utf8 chars which was Gitea dropped.
@42wim commented on GitHub (Jun 19, 2022):
Ok, closed PR
@zeripath commented on GitHub (Jun 19, 2022):
This was my worry when the email character restrictions were merged. There is really only one thing we should not be allowing outside of RFC5322:
-but even that is really not our responsibility - it's only a problem with those running sendmail commands and the way they've configured the command. It should probably be an optional setting.
I think that UTF-8 should be allowed - at least optionally - we're no longer in the 80s and whilst the majority of email addresses are still using only basic ASCII it's not really right to still be restricting in this matter. If there are issues with ambiguous characters (and there would be) we can fix the display of those (and in fact #19990 would provide the mechanism for doing this.)
@oott123 commented on GitHub (Aug 1, 2022):
How about
user@some-domain.com? Dashes in domain names is very common.@theAkito commented on GitHub (Dec 3, 2022):
Many websites get this one wrong, because web developers are too lazy.
_@mail.comis a perfectly valid e-mail address.@zeripath commented on GitHub (Dec 3, 2022):
This feels like something that is going to go round and round in circles.
The restriction is in:
0e46499258/models/user/email_address.go (L145-L168)If you want to change/relax this you will need to make a PR that changes the code here.
You will also need to consider:
-should be all that needs.Code speaks louder than words. Make the PR.
@lunny commented on GitHub (Dec 7, 2022):
Hi, as a comparison. Gmail has a very restriction for email name(Only characters and digitals), and Github also doesn't allow unicode characters. And I also found another ref to support that https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#basic_validation.
Please focus on the issue itself and don't say anything else, otherwise you will be ban.
@zeripath commented on GitHub (Dec 8, 2022):
I think we should be careful here to note that git will allow these extremely weird email addresses and Gitea will just use them.
So by having this super-restrictive pattern we're not preventing weird and ambiguous email addresses from appearing in Gitea - just preventing the user from saying that one belongs to them.
Further, the potential problem of email addresses being ambiguous/confusable with another user isn't particularly a much worse issue as the Gitea will not show the email address and will show the user that they map to instead. Thus unicode ambiguity of email addresses should only affect the user who the ambiguous email address belongs to.
Next we should consider if there are potential sec issues by allowing arbitrary email addresses.
-seems to be all that is needed.As far as I can see the only person affected by Gitea allowing users to register their own weird email address is the user itself. Thus apart from blocking the initial
-I can't see a good reason for further restriction beyond RFC5322.I might be missing something though - does anyone have any other ideas?
@mqudsi commented on GitHub (Jan 8, 2023):
The myth about the no leading
-restriction is, so far as I can determine, from people that aren't aware of how to interact with unix command line utilities.Under both Linux and BSD,
sendmail, like pretty much all other CLI utilities, should be invoked with a--argument after the flags you wantsendmailexecuted with. All arguments supplied after--are parsed as literal payload values and are not considered flags/switches tosendmail.This should also be the case with all the other popular sendmail alternative MTAs like postfix and the rest.
Sure, it's possible that some ancient version of a popular MTA didn't support
--and this workaround was required (though basic unix utilities have had to support this from forever ago in order for you to create or delete a file name-so it's not some really advanced wizardry) but an MTA that old should probably not be connected to the internet as it surely has bigger problems than not supporting the venerable--syntax (cough security vulnerabilities cough).@delvh commented on GitHub (Jan 8, 2023):
That is exactly the problem: If we allow leading
-, there will always be someone who somehow forgets to prepend--to his sendmail command.While Gitea should handle all its sendmail code correctly, that is not necessarily the case for all subsequent tools we have no influence over that for example query the email from the API.
I don't even know why you would want an email address that starts with
-.It might be allowed but the only benefits it grants are "trolling" insecure applications and annoying senders who want to send you an email.
@theAkito commented on GitHub (Jan 8, 2023):
Non-argument. You can say that about any option & any command. If you don't know what you are doing, you can do everything the wrong way.
Exhibit A
The find command.
If you don't know, that this antiquated tool from pre-historic stone ages is using single dashes for long options, you are just as lost. Yet, this tool is (sadly) used all over the world & people deal with it.
So, if they can deal with this pre-historic piece made by a caveman, they can deal with a simple inbetween double dash.
Non-argument. Even more so, than the last one.
Exhibit A
"I don't even know why you would want a nickname like 'delvh', like why? Why not use your real name or a normal English word?" - someone could ask.
If something is not forbidden, why make it "undesired" by convention? Such actions are usually much more confusing than an unusual case within the frame of what is allowed, because then you have millions of conventions, which are basically unwritten "rules" one "must" (not really) follow.
Therefore, if it is allowed & according to the spec, it should work. Simple as that.
If someone does not use a double dash or quotes or whatever options there are & then blaming the software design for it, is pretty much like saying "well, someone could type
ls --linstead ofls -l, so we must make it work with a double dash, as well" or something along those lines.@mqudsi commented on GitHub (Jan 9, 2023):
Just a reminder that this email filter doesn't really have anything to do with weird emails making their way into the database. Email addresses still get pulled in from git commits and stored in the db as-is, without going through this filter.
Regardless, "someone might not know how to handle this" isn't really Gitea's problem.
@gilbertoca commented on GitHub (Feb 28, 2024):
@lunny @Zettat123
I'm here, after jump to 1.20.0 from 1.19.4.
Can't change anything on Edit User Account since this e-mail gilberto.bispo@ibrowser.net.br is invalid.
Does it have anything with #27457?
Our users are from smtp servers with different domains.
@lunny commented on GitHub (Feb 29, 2024):
The email you mentioned is considered as valid at least on main branch. What's the error when you edit it?
P.S. If the email hasn't been activated, users can only login with their name but not email address.
@gilbertoca commented on GitHub (Feb 29, 2024):
@lunny @Zettat123 I blurred the username field for user protection and put another e-mail. I've tested several e-mail id but with the same domain and got the error message.
@lunny commented on GitHub (Feb 29, 2024):
OK. I think I just tested plain user but not SMTP user. I will test your use case.