Skip to content

Commit 04ac682

Browse files
fix: non-lowercasing all ascii
1 parent 5410d39 commit 04ac682

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ fn x520_mapped_to_nothing(c: char) -> bool {
311311
/// spaces as described in Section 7.6, because the characters needing removal
312312
/// will vary across the matching rules and ASN.1 syntaxes used.
313313
pub fn x520prep(s: &str, case_fold: bool) -> Result<Cow<'_, str>, Error> {
314-
if s.chars().all(|c| matches!(c, ' '..='~')) {
314+
if s.chars().all(|c| matches!(c, ' '..='~') && (!case_fold || c.is_ascii_lowercase())) {
315315
return Ok(Cow::Borrowed(s));
316316
}
317317

@@ -399,6 +399,7 @@ mod test {
399399
assert_eq!(x520prep("foo@bar", true).unwrap(), "foo@bar");
400400
assert_eq!(x520prep("J.\u{FE00} \u{9}W.\u{9} \u{B}wuz h\u{0115}re", false).unwrap(), "J. W. wuz h\u{0115}re");
401401
assert_eq!(x520prep("J.\u{FE00} \u{9}W.\u{9} \u{B}wuz h\u{0115}re", true).unwrap(), "j. w. wuz h\u{0115}re");
402+
assert_eq!(x520prep("UPPERCASED", true).unwrap(), "uppercased");
402403
assert_prohibited_character(x520prep("\u{0306}hello", true));
403404
}
404405

0 commit comments

Comments
 (0)