Repository navigation
Apply the IDNA Bidi Rule to every label of a Bidi domain - #188
Conversation
The idna package checks the RFC 5893 Bidi Rule only on labels that contain right-to-left characters. RFC 5893 and UTS JoshData#46 CheckBidi require every label to satisfy it once any label does, so domains like 1.אב.com and אב.1.com were both accepted although they render identically.
|
Huh, interesting. Did you encounter this in the wild, or is this an AI-found hypothetical? I'm pleasantly bemused that one of the cases RFC 5893 addresses is Yiddish (a personal interest as an Ashkenazi Jew). Anyway, I'd be glad to include. But: I would like to avoid the odd Unicode actually appearing in the source code, because that now makes the library's source code hard to read. I had to plug them into (my site) https://unicode.run (a, b) to see the difference. Would you revise the PR so that the test uses the IDNA ASCII (1.xn--4dbc.com, xn--4dbc.1.com) primarily and put the Unicode in a code comment, and revise the code comment in the main part and the CHNAGELOG to include the IDNA ASCII? I also wonder if this should be handled by the upstream idna library instead. A PR there might be of interest. |
|
Switched the tests to On upstream: agreed it would fit better in idna. Right now |
|
TY! |
validate_email_domain_name leaves the RFC 5893 bidi rule to idna.alabel and idna.encode, but the idna package only checks labels that themselves contain right-to-left characters. RFC 5893 section 1.4 and UTS #46 CheckBidi apply the rule to every label once any label has an R, AL or AN character, so
x@1.אב.comandx@אב.1.comwere both accepted as different addresses (1.xn--4dbc.comvsxn--4dbc.1.com) even though the bidi algorithm displays both asx@1.בא.com, which is the spoofing case the rule exists to prevent. the check now runs idna.check_bidi(label, check_ltr=True) on each label of the decoded domain when any rtl character is present, so A-label input likeme@1.xn--4dbrk0ceis covered too, while ordinary rtl domains such asexample.ישראלandمثال.إختبارstill validate. one existing length test had digit-led labels after a hebrew label, so those labels now start with a letter and the test still checks the length message.