mirror of
https://github.com/shred/acme4j.git
synced 2025-12-16 11:24:01 +08:00
Use en locale for uppercase/lowercase (fixes #156)
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
package org.shredzone.acme4j;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* An enumeration of status codes of challenges and authorizations.
|
||||
@@ -84,7 +85,7 @@ public enum Status {
|
||||
* no match
|
||||
*/
|
||||
public static Status parse(String str) {
|
||||
var check = str.toUpperCase();
|
||||
var check = str.toUpperCase(Locale.ENGLISH);
|
||||
return Arrays.stream(values())
|
||||
.filter(s -> s.name().equals(check))
|
||||
.findFirst()
|
||||
|
||||
@@ -183,7 +183,7 @@ public final class AcmeUtils {
|
||||
*/
|
||||
public static String toAce(String domain) {
|
||||
Objects.requireNonNull(domain, "domain");
|
||||
return IDN.toASCII(domain.trim()).toLowerCase();
|
||||
return IDN.toASCII(domain.trim()).toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -307,7 +307,7 @@ public final class AcmeUtils {
|
||||
if (charset != null && !"utf-8".equalsIgnoreCase(charset)) {
|
||||
throw new AcmeProtocolException("Unsupported charset " + charset);
|
||||
}
|
||||
return m.group(1).trim().toLowerCase();
|
||||
return m.group(1).trim().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.shredzone.acme4j;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
@@ -27,8 +29,11 @@ public class StatusTest {
|
||||
*/
|
||||
@Test
|
||||
public void testParse() {
|
||||
// Would break toUpperCase() if English locale is not set, see #156.
|
||||
Locale.setDefault(new Locale("tr"));
|
||||
|
||||
for (var s : Status.values()) {
|
||||
var parsed = Status.parse(s.name().toLowerCase());
|
||||
var parsed = Status.parse(s.name().toLowerCase(Locale.ENGLISH));
|
||||
assertThat(parsed).isEqualTo(s);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user