Skip to content

Commit f0cefd6

Browse files
committed
fix: Use Locale.ROOT for toLowerCase() in domain comparison
Addresses PR review feedback — locale-independent case folding prevents unexpected behavior in non-English locales (e.g., Turkish).
1 parent 5ba86c4 commit f0cefd6

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/main/java/com/digitalsanctuary/spring/demo/registration/DomainRegistrationGuard.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.digitalsanctuary.spring.demo.registration;
22

3+
import java.util.Locale;
4+
35
import org.springframework.context.annotation.Profile;
46
import org.springframework.stereotype.Component;
57

@@ -49,7 +51,7 @@ public RegistrationDecision evaluate(RegistrationContext context) {
4951
}
5052

5153
// For form/passwordless, restrict to the allowed domain
52-
if (context.email() != null && context.email().toLowerCase().endsWith(ALLOWED_DOMAIN)) {
54+
if (context.email() != null && context.email().toLowerCase(Locale.ROOT).endsWith(ALLOWED_DOMAIN)) {
5355
log.debug("Allowing registration for approved domain: {}", context.email());
5456
return RegistrationDecision.allow();
5557
}

0 commit comments

Comments
 (0)