mirror of
https://github.com/yushijinhun/authlib-injector.git
synced 2024-11-15 06:11:09 +01:00
fix #81
This commit is contained in:
parent
14741ad521
commit
e913d7d4d4
2 changed files with 13 additions and 4 deletions
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package moe.yushi.authlibinjector.httpd;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.ISO_8859_1;
|
||||
import static java.util.Optional.empty;
|
||||
import static java.util.Optional.of;
|
||||
import static java.util.Optional.ofNullable;
|
||||
|
@ -65,6 +66,10 @@ public class LegacySkinAPIFilter implements URLFilter {
|
|||
return empty();
|
||||
String username = matcher.group("username");
|
||||
|
||||
// Minecraft does not encode non-ASCII characters in URLs
|
||||
// We have to workaround this problem
|
||||
username = correctEncoding(username);
|
||||
|
||||
Optional<String> skinUrl;
|
||||
try {
|
||||
skinUrl = upstream.queryUUID(username)
|
||||
|
@ -104,4 +109,9 @@ public class LegacySkinAPIFilter implements URLFilter {
|
|||
.map(JsonUtils::asJsonString)
|
||||
.orElseThrow(() -> newUncheckedIOException("Invalid JSON: Missing texture url")));
|
||||
}
|
||||
|
||||
private static String correctEncoding(String grable) {
|
||||
// platform charset is used
|
||||
return new String(grable.getBytes(ISO_8859_1));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,8 +46,7 @@
|
|||
*/
|
||||
package moe.yushi.authlibinjector.internal.fi.iki.elonen;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.US_ASCII;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.ISO_8859_1;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
@ -360,7 +359,7 @@ public abstract class NanoHTTPD {
|
|||
}
|
||||
|
||||
// Create a BufferedReader for parsing the header.
|
||||
BufferedReader hin = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(buf, 0, this.rlen), US_ASCII));
|
||||
BufferedReader hin = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(buf, 0, this.rlen), ISO_8859_1));
|
||||
|
||||
// Decode the header into parms and header java properties
|
||||
Map<String, String> pre = new HashMap<>();
|
||||
|
@ -486,7 +485,7 @@ public abstract class NanoHTTPD {
|
|||
}
|
||||
if (expect100Continue && !continueSent) {
|
||||
continueSent = true;
|
||||
this.outputStream.write("HTTP/1.1 100 Continue\r\n\r\n".getBytes(US_ASCII));
|
||||
this.outputStream.write("HTTP/1.1 100 Continue\r\n\r\n".getBytes(ISO_8859_1));
|
||||
}
|
||||
}
|
||||
return this.parsedInputStream;
|
||||
|
|
Loading…
Reference in a new issue