|
@@ -220,17 +220,21 @@ fn passes_bidi(label: &str, is_bidi_domain: bool) -> bool {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// http://www.unicode.org/reports/tr46/#Validity_Criteria
|
|
/// http://www.unicode.org/reports/tr46/#Validity_Criteria
|
|
|
|
|
+fn validate_full(label: &str, is_bidi_domain: bool, flags: Flags, errors: &mut Vec<Error>) {
|
|
|
|
|
+ // V1: Must be in NFC form.
|
|
|
|
|
+ if label.nfc().ne(label.chars()) {
|
|
|
|
|
+ errors.push(Error::ValidityCriteria);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ validate(label, is_bidi_domain, flags, errors);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
fn validate(label: &str, is_bidi_domain: bool, flags: Flags, errors: &mut Vec<Error>) {
|
|
fn validate(label: &str, is_bidi_domain: bool, flags: Flags, errors: &mut Vec<Error>) {
|
|
|
let first_char = label.chars().next();
|
|
let first_char = label.chars().next();
|
|
|
if first_char == None {
|
|
if first_char == None {
|
|
|
// Empty string, pass
|
|
// Empty string, pass
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // V1: Must be in NFC form.
|
|
|
|
|
- else if label.nfc().ne(label.chars()) {
|
|
|
|
|
- errors.push(Error::ValidityCriteria);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
// V2: No U+002D HYPHEN-MINUS in both third and fourth positions.
|
|
// V2: No U+002D HYPHEN-MINUS in both third and fourth positions.
|
|
|
//
|
|
//
|
|
|
// NOTE: Spec says that the label must not contain a HYPHEN-MINUS character in both the
|
|
// NOTE: Spec says that the label must not contain a HYPHEN-MINUS character in both the
|
|
@@ -322,12 +326,13 @@ fn processing(domain: &str, flags: Flags, errors: &mut Vec<Error>) -> String {
|
|
|
match punycode::decode_to_string(&label[PUNYCODE_PREFIX.len()..]) {
|
|
match punycode::decode_to_string(&label[PUNYCODE_PREFIX.len()..]) {
|
|
|
Some(decoded_label) => {
|
|
Some(decoded_label) => {
|
|
|
let flags = Flags { transitional_processing: false, ..flags };
|
|
let flags = Flags { transitional_processing: false, ..flags };
|
|
|
- validate(&decoded_label, is_bidi_domain, flags, errors);
|
|
|
|
|
|
|
+ validate_full(&decoded_label, is_bidi_domain, flags, errors);
|
|
|
validated.push_str(&decoded_label)
|
|
validated.push_str(&decoded_label)
|
|
|
}
|
|
}
|
|
|
None => errors.push(Error::PunycodeError)
|
|
None => errors.push(Error::PunycodeError)
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ // `normalized` is already `NFC` so we can skip that check
|
|
|
validate(label, is_bidi_domain, flags, errors);
|
|
validate(label, is_bidi_domain, flags, errors);
|
|
|
validated.push_str(label)
|
|
validated.push_str(label)
|
|
|
}
|
|
}
|