From 576e42298c59df456b8fcacd46a94e9ecd764c7a Mon Sep 17 00:00:00 2001 From: Marcus Comstedt <marcus@mc.pp.se> Date: Mon, 31 Mar 2003 18:10:03 +0200 Subject: [PATCH] This should be more according to the standard... Rev: lib/modules/Standards.pmod/IDNA.pmod:1.5 --- lib/modules/Standards.pmod/IDNA.pmod | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/modules/Standards.pmod/IDNA.pmod b/lib/modules/Standards.pmod/IDNA.pmod index d3f1b1173c..0928adbe3b 100644 --- a/lib/modules/Standards.pmod/IDNA.pmod +++ b/lib/modules/Standards.pmod/IDNA.pmod @@ -380,8 +380,10 @@ string to_ascii(string s, int(0..1)|void allow_unassigned, int(0..1)|void use_std3_ascii_rules) { int is_ascii = max(@values(s)) < 128; - if(!is_ascii) + if(!is_ascii) { s = nameprep(s, allow_unassigned); + is_ascii = max(@values(s)) < 128; + } if(use_std3_ascii_rules) { if(array_sscanf(s, "%*[^\0-,./:-@[-`{-\x7f]%n")[0] != sizeof(s)) error("Label is not valid accoring to STD3: non-LDH codepoint\n"); @@ -409,18 +411,19 @@ string to_ascii(string s, int(0..1)|void allow_unassigned, //! The sequence of Unicode code points to transform. string to_unicode(string s) { + string s0 = s; if(max(@values(s)) >= 128 && catch(s = nameprep(s, 1))) - return s; + return s0; if(lower_case(s[..3]) != "xn--") - return s; - string orig_s = s; + return s0; + string ascii_s = s; catch { s = Punycode->decode(s[4..]); - if(lower_case(to_ascii(s, 1)) == lower_case(orig_s)) + if(lower_case(to_ascii(s, 1)) == lower_case(ascii_s)) return s; }; - return orig_s; + return s0; } -- GitLab