You shouldn't be comparing the mailbox part of email addresses at all other than as literal bytestrings: you cannot know what equivalence rules the mailserver for that domain uses.
The domain part can be equivalence-tested using the normal rules for domains though, including case insensitivity, IDN translation and punycode resolution.
You're right in general. In my specific post, I do know the equivalence rules, because I'm administering the mail system and working with its source code, and the documentation guarantees/requires that internally its email addresses are treated entirely as case-insensitive.
What I saw was source code comments about not using `lower(x)` nor Postgres module `citext`, and instead using Unicode case folding ICU and Postgres non-deterministic collations. In the end, what surprised me wasn't about email servers in general, it was about human languages with case folding.
It's hard to know what to do in practice, but this seems to be wrong according to https://www.rfc-editor.org/rfc/rfc6532#section-3.1: "normalization form NFC SHOULD be used".
However, if you just want to make sure this is the same user that signed in earlier, you get to chose what rules you want - it's their problem to some extent to remember what account name they gave you.
My solution was subscribing "[email protected]" to the same list.
if "@" in email:
send_confirmation(email) sdchema!mhtsa!australia!chris@NoscThis works in gmail for both sending and receiving, although sending as [email protected] requires messing around in the settings[2] and having to remember to select a non-default From: address in your outgoing mail.
[1]: https://alexshroyer.com/posts/2022-09-01-Default-Honeypot.ht... [2]: https://webapps.stackexchange.com/questions/3598/is-there-an...
Allow-list isn't the worst, but this isn't a long-term solution in and of itself
Never saw this +string before? Mark as spam.
Is the +string missing? Spam.
Recognize this +string from your "Sent" folder? Keep.
Signing up for something? Generate a pseudorandom +string and add it to the allow-list.
Not all providers are Gmail.
My point is that there is no standard that you can use to decide if two email addresses refer to the same inbox.
Each provider has their own rules for what emails they consider identical, and you need to either invent your own rules, or learn what theirs are, depending on why you are doing this.
Using Unicode aware string comparisons doesn't solve the issue any more than byte-wise comparison or ascii case-insensitive comparison.
You can't reliably say that a.b@ and ab@ are the same user except in a very small population (gmail.com) because you don't know how other domains will handle it.
Email is not a unique identifier which is how they're wanting to use it.
Badly worded on my part.
But, if you're using the email as a username just for convenience, you get to decide what rules you have for username comparison. You can absolutely decide that [email protected] and [email protected] are different accounts for your service, even though emails you send to these accounts will likely reach the same inbox. You can also decide that they are the same account, but that haş[email protected], HAŞ[email protected] and HAŞİ[email protected] are all different accounts. It's entirely up to you to know what is important for your users.
It's part of the reason why you see many places ask for your phone number, not that I agree with that, and even this method has many flaws.
Instead, all anyone offers in this vein are identifiers that are really annoying to get and that nobody already has as a matter-of-course of registering a company; such that many real companies can't (or won't bother to) pass them. DUNS numbers are a common choice. Our company is five years old and doesn't have a DUNS number. It takes two weeks to get one. So how could I expect our customers to bother getting one just to try our product?
Of course in principle you can get an EV cert for any company as well, but now we're talking about determining whether a company is sufficiently well-known to accept, which is not something that can fully be solved deterministically since that's a human judgement, there will always be some grey areas. But, there are certainly a lot of companies that could probably be "automatically verified" in some fashion (ford motor company? reasonably well-known, and this is their domain...) given some sort of authoritative domain -> stock mapping, and that's not impossible to do if you trust the EV scheme.
Anyway, not perfect, but challenges based raises the bar a lot from "register domain with godaddy and sign up for let's encrypt" to "first you have to get an EV certificate..."
Of course, since such a mechanism is not widely used... not exactly going to find tons of official support for using it like that. But the mechanisms are there!
Also, as a slight tweak, I'd hope that this authentication scheme would only admit legal companies that are at least a week old. People who do these sorts of bulk-registration attacks tend not to be patient people, willing to wait around for their credentials to gain reputation before using them. They create them and then try to use them right away. Whereas no real company would be signing up for most B2B services in its first week of legal existence. (Google Workspace? Sure. Accounting software? Probably not.)
If it's targeted to X company for a specific reason, they'll wait however long they need. If it's generic and X company is just caught in the crossfire, then maybe.
>Whereas no real company would be signing up for most B2B services in its first week of legal existence. (Google Workspace? Sure. Accounting software? Probably not.)
When I've registered companies in the past, it's when I have sales. Before then, it's just an idea to see if we get users. But the company with the service can determine that.
(You don't have to be petty about it; no need to send them to a "you're an attacker" page or anything. Just redline the form-field, explain the problem clearly, and let them modify the address until it's less duplicable.)
Yes, this doesn't stop people from manually registering multiple times, since, as you say, people can have multiple addresses; or even email service from multiple providers. But it does stop low-effort automated bulk-registration attacks. And some services — those with any sort of free-tier especially — get a lot of those!
It's a 100% valid character to use. Doesn't have to mean it's a label in another hostname. Goes back to what others have said. You either end up with a ton of rules, or go with the fact that email isn't the best solution to identify unique users.
https://en.wikipedia.org/wiki/Email_address#Local-part
> The local-part of the email address may be unquoted or may be enclosed in quotation marks.
>If unquoted, it may use any of these ASCII characters:
> - uppercase and lowercase Latin letters A to Z and a to z
> - digits 0 to 9
> - printable characters !#$%&'*+-/=?^_`{|}~
> - dot ., provided that it is not the first or last character and provided also that it does not appear consecutively (e.g., [email protected] is not allowed).[5]
> If quoted, it may contain Space, Horizontal Tab (HT), any ASCII graphic except Backslash and Quote and a quoted-pair consisting of a Backslash followed by HT, Space or any ASCII graphic; it may also be split between lines anywhere that HT or Space appears. In contrast to unquoted local-parts, the addresses ".John.Doe"@example.com, "John.Doe."@example.com and "John..Doe"@example.com are allowed.
(it keeps going on the wikipedia page)
(It's a similar "you're really relying on perfect competence from the whole rest of the ecosystem to get you out of this" feeling as e.g. putting a space in your user name — and thus your home directory path — in Linux. Sure, the core GNU/BSD/etc tooling has been tested for that use-case — but are you really going to trust random tools and shell-scripts to handle argument tokenization perfectly? Or are you just going to ditch the space to be safe?)
It would probably be the other way.
The more technical literate a user is, the more they'll understand and figure out how things work, the nuances, and use those things.
You know that core tooling that works? It's because technical literate users, tried it, found the issue, and fixed it.
Same way with me using é on my name. If something breaks on a website, email, etc, I create an issue and starts emailing. My name doesn't have an e, it has an é.
the fundamental problem here is assuming that "emailA == emailB" could ever conceivably be used as a proxy of the equality "userA == userB". Unicode tarpits aside (that's a legitimate problem where even if you did everything exactly right, libraries or api calls etc might not) the idea of "do these mailboxes belong to the same user" (in the sense of stripping '+' suffixes from gmail boxes etc) cannot be answered period. You cannot affirmatively confirm this nor can you disprove the assertion either, without some additional information about the behavior of the receiving mail transport agent.
even if you understand the behavior of the receiving MTA, you cannot prove that they don't have an email account somewhere else, so that is not sufficient either.
email is not a key for user uniqueness, period. It's a channel for contacting a user. You don't mess with it, and you simply send an email and see if the session user can authenticate it. If you want identity verification that happens at another layer, not email.
"transforms" like lowercasing or mailbox-suffix-stripping are only window dressing patching around this fundamental issue. There is no way to affirmatively go from "email address" to "user identity" without more information from another layer. It's a communication channel, not an identity provider. You can (reasonably) use it as a medium to talk to the user while you verify them against something else (although like SMS it can of course be hijacked unless your IDP protocol accounts for this possibility) but "email verification" is not and can never be an IDP in itself. Gmail addresses are free.
I have a few accounts. Those + suffixes drive a bunch of rules on them to get me to take action. They forward to my primary email address if it's important.
Some of them get scraped and mailed in a weekly summary. Some of them send text messages alerting me.
When they mess with them, I'll probably just not see it unless I have to login for some other reason to that account.
Verbs and argument values (e.g., "TO:" or "to:" in the RCPT command and extension name keywords) are not case sensitive, with the sole exception in this specification of a mailbox local-part.
you can include quoted spaces, carriage returns and newlines (!)
Sure. At the user signup side, block emails that are too close in ways like case, but as a sender you should always treat them as unique emails.
Languages that don't have case is not an issue; the situations where a lowercase <-> uppercase mapping is not simple are actually not that many. It's not trivial, but not all that complex either. The most annoying part is Turkish, Azeri, and Lithuanian where the rules differ a bit but the used language is often unknown. For the purpose of matching things ("is this email address known in our system?") it's actually not that hard, since you can just treat several characters as identical (displaying text correctly to users is harder, but that's not important here).
I see this attitude in various situations, often under "falsehoods programmers believe" articles, which goes something like "it's hard in a few rare cases, therefore we should not do it at all for the >99% cases where it's simple and unproblematic".
edit: wow. goodbye gmail
"if your email is [email protected], you own all dotted versions of your address:
[email protected] [email protected] [email protected]"
>[email protected] and [email protected] are the same address and go to one inbox
I have an account with the dot, that was made in age, when Gmail was invite-only. Few years ago, someone created an account without the dot. Yes, I'm receiving their mail, and have no way to contact them, because everything I send out comes back to me.
My coworker told me there's a complete stranger who, every time she emails her son, accidentally sends the email to him first. This has been going on for years, she makes the same mistake every time, she doesn't learn her son's actual email address, and she doesn't learn to press "reply."
I'm 100% sure the "non-dot-version" doesn't exist as a separate account.
Google’s gmail people aren’t really as smart as they think they are.
That Another John Doe never, ever had access to [email protected], they just gave a wrong address. That's not gmail's fault.
This. My wife and I have two flavors of this.
Her address is [email protected]. There people frequently forget the m initial and somebody else owns [email protected] She's since started using dots first.m.last to mitigate the error.
My address is firstlast@gmail, where first and last are not globally common, but are fairly common in Scotland. Once a year or so, I receive email for somebody else that shares my name. I don' know his real email, but I've been "invited" on his family vacations 3-4 times now. Infrequent enough that I just respond "thanks for the invite, but I think you'll be disappointed when I arrive and not the Alistair you were expecting."
It's actually not a super common first and last, so firstlast@ knows when to who to forward.
I signed up for my university's email forwarding for alumni early on and got my first name as my email. For quite a while, I would get emails, including fairly sensitive ones, sent to me by not yet very email savvy people just assuming you could send an email to someone's first name and it would get to them.
I received 2-3 personal emails, but most of them are automated invoices.
Nobody else can register an email that is the same as yours but without a dot. So the only way you receive someone else's email is if they give the wrong address.
That's not my experience. Which non-gmail email software ignores dots before the @?
Thinking about this, I guess the sending MTA doesn't care about dots; it goes RCPT TO: <[email protected]>. The receiving MTA then has to validate that address; it does that using some account database that isn't typically part of the MTA - it could be a unix account (no dots!), a database table, or an LDAP user. Finally it passes the mail off to a delivery agent, which hopefully relies on the same account database.
So the elision of dots appears to be a feature of certain account databases. So which account databases elide dots?
[0] https://www.postfix.org/ADDRESS_REWRITING_README.html#virtua...
I guess this is another falsehood people believe about emails.
> Nobody else can register an email that is the same as yours but without a dot.
It used to be possible, then google decided to stop allowing that (guess why?)
And by the way, that’s an arbitrary decision.
I have run mail servers and it’s just and cam tell you… it’s an arbitrary decision.
Yeah. That's fine.
If my email is [email protected] because I want to be cute I have to tell people to type exactly the right number of L's. Do you think they should just be able to type a lot of L's and as long as it's somewhere near it counts as the same email address?
In a world where email addresses are always case sensitive, everyone will use lowercase (like they pretty much always already do anyway), and it'll be fine.
This in itself sounds is a falsehood!
In a world where email addresses were "obviously" case sensitive, "LLL" mapping to "lll" would be just as crazy as "LLLLLLLLLL" mapping to "LLLLLLLLLLL".
They just seem similar, to humans. But they're different strings.
Ah, youth. There was little choice! Sometimes you had only six bits for a character; sometimes your bytes could be from 1-36 bits wide, depending on what you wanted for your program, so you might have systems that mixed six-bit (only upper case) and early ascii (two cases) and so for matching you had to be case insensitive.
It’s easy to look back and say “those people were so stupid” but they weren’t.
E-Mail wouldn't have been widely accepted with case sensitive addresses.
People expect that [email protected] reaches the same person like [email protected] or [email protected] just like letters reach their recipient irrespective of the upper and lower case of the recipient's name.
Computers are there to make the lives of the users easier, not the programmers.
However it being insensitive has probably helped a lot of times where people make mistakes in explaining or copying those capitals.
Similar to how gmail ignores . in emails but other hosts do not.
I don't think they really do. They may think case matters somehow, and so may be careful to reproduce the exact case that they used before, but I don't think many people would expect [email protected] and [email protected] to be too different email accounts.
original ASCII only had uppercase. When lowercase got added, gradually with newer systems and software, without case insensitivity you would have had massive incompatibilities which probably would have hampered or even arrested the introduction of lowercase in new systems
and all over again, when microcomputers first came out, they came out with uppercase only to cut complexity and cost on simple systems.
i'm not going to explore the entire history, but just looked this up. TL;DR example, the addition of lowercase characters represented a jump from 6 bits to 7 bits at the hardware level:
"A six-bit character code is a character encoding designed for use on computers with word lengths a multiple of 6. Six bits can only encode 64 distinct characters, so these codes generally include only the upper-case letters, the numerals, some punctuation characters, and sometimes control characters. The 7-track magnetic tape format was developed to store data in such codes, along with an additional parity bit."
Fun fact: the reason we pronounce "ph" like "f" is because the Greek letter was originally pronounced like p-h, at the time Romans began stealing words, but then the Greeks started pronouncing it like "f" and the Romans followed suit, but kept the old Latinization of "ph", because they'd already carved it into stone.
English spelling is largely phonetic... but it captures the phonetic spelling across dozens or hundreds of shifts in the spoken language. Unless you can stop people from changing how they speak, any phonetic spelling reboot is either going to suffer from the same problem, or words will constantly change how they are spelled to keep up with the spoken word.
It also helps to limit the fragmentation of pronunciation of words.
conversely it's certainly been an obvious disadvantage (posed a lot of problems and imposed a lot of awkward workarounds) for mechanical/electronic communication - now you have to enter the characters too, and you have to express that larger number of characters efficiently. In practice, a lot of electronic communication is just simplified to ASCII because that's the set that works universally. Someone used the example of ess-tset being transliterated as "ss" in german, dunno if chinese uses anything similar, but it wouldn't surprise me, obviously Japanese has romaji too.
but at a human-interface level, fundamentally there is a limit to how many symbols people can absorb. Even with latin characters, people at best will sight-read whole words to increase symbol rate, but, the natural evolution is to use 1 character to represent 1 symbol/word, that's the highest possible rate at which humans can absorb symbols for a written system. And in turn you could in principle absorb a "word of symbols", which is a sentence, similar to how western readers can sight-read a word of our 1-character glyphs.
by "increasing the dimensionality" of the symbol, you increase the effective symbol rate, similar to how memes use subtext/etc to convey more nuance than a pure text can by itself.
This is already how it works. Senders are not supposed to assume that local-parts are case-insensitive. (Some buggy implementations ignore this requirement and upper-case everything, but the serious implementations don’t).
You also don't get to argue with the fusional position changes in Arabic, or the ligatures in Devanagari, or the places within a square the featural particles of Hangul must be printed in.
These things aren't negotiable.
Of course, most languages aren't written at all ... or at least don't have a traditional written form that is sufficiently well established for someone to say that the "language" has case rather than a particular (proposed) way of writing it.
However, I rather suspect that the majority of languages in which books are published use some variant of the Latin alphabet and do, therefore, have case. (The only language I've heard of that uses the Latin alphabet without case is Lojban!)
On the other hand, if you weight languages by the number of (native) speakers, since about three quarters of the world's population lives in China, India, Pakistan, Bangladesh, Japan or Korea, probably it's true that most people don't use case in their main language.
Case is only used in a few alphabets, mainly Latin-, Cyrillic-, and Greek-derived ones.
For that matter typesetting rules vary by language as well — not just the obvious hyphenation rules busnspacimg as well. Just pick up a book in, say, French or Russian and you can tell at a glance (without even looking at the letters) that it’s not in English.
However, I don't agree with your point about typeset text. You're right that the styles differ, but if you have learned one style, and know the language of the text, you will not need any significant amount of time to read a different style of typesetting.
Russian of course normally uses the Cyrillic alphabet, not the Latin one, so obviously you do have to learn a whole new set of symbols to understand it even if you can read Latin symbols. And of course French uses slightly more letters/letter forms than English, with the sedile and four accents (egu, grave, circonflex, and very rare treme).
I didn’t mean the typesetting differences made reading a different language in any way hard, merely pointing out that there are lots of different aspects to text in different languages even when the alphabets are basically the same.
Oh, you want speakers? merely counting people who read Hanzi + Arabic-Alphabet readers + the Indian subcontinent gets you more half the world‘s population. And there are hundreds, maybe over a thousand writing systems.
Latin is much more wide-spread than that! You neglect whole of America and Australasia and half of Africa.
https://upload.wikimedia.org/wikipedia/commons/9/9d/Writing_...
> So a big imbalance!
When we sum up realistically, then world-wide the amount of users of writing systems with case/"cameral" are about equally balanced with those without.
Fx in danish we have 3 letters (æøå) that is not common in the latin alphabet. I cant go to germany or turkey and expect people to be able to write out those letters when doing input in a local system.
Germany relatively adopted an uppercase ß (and got it into Unicode) to try to help with case roundtripping but I’ve never seen it in the wild. And let’s not get into obsolete German Fraktur ligatures like tz or ch which also had no upper case equivalents.
The parenthetical part is true. It was an uphill battle, but not because of the consortium, but because of what the tropes wiki would describe as executive meddling.
The adoption is not recent, but about 110 years old. You have the wrong idea because of sloppy journalism.
> I’ve never seen it in the wild
I see it all the time. Maybe you are undercounting. Pay attention to non-standard letterforms on hand-written signs, and you also have to include print media where someone substituted lower-case ß in absence of a glyph in a font. This is a typographic mistake, but the intent is clear.
I don't think that's right. It's used in certain contexts like all caps.
what is inside that function?
func string-compare-case-insensitive(x, y) {
return lower(x) == lower(y) ? lower(x) == lower(y) : lower(x) == lower(y);
}
/sMore seriously, if you want to learn about this, one place is to look at OpenJDK's sources. E.g. here:
https://github.com/openjdk/jdk/blob/master/src/java.base/sha...
which calls: https://github.com/openjdk/jdk/blob/17283cfe4c697e2118f19992... and https://github.com/openjdk/jdk/blob/17283cfe4c697e2118f19992...
Or, more likely, by using a library like ICU.
Care to explain in more detail?
See the standard https://www.unicode.org/versions/Unicode11.0.0/ch05.pdf for the most commonly used example of Turkish i, but there are others.
> the full case foldings are superior: for example, they allow "MASSE" and "Maße" to match.
Yes in the basic SMTP RFC, but there are extensions that allow non-ascii local-parts.
An email system that guarantees case-insensitive email addresses can still fail during comparisons of lowercase-to-lowercase, due to international encodings, locales, I18N, L10N, etc.
Pseudocode:
It turns out this issue is called a "case folding non-deterministic" error, and is a broader issue with strings in general.For more about "case folding" with Unicode: http://www.unicode.org/Public/UNIDATA/CaseFolding.txt
For more about "non-deterministic" comparisons: https://www.postgresql.org/docs/current/collation.html#COLLA...