mirror of
https://github.com/unmojang/authlib-injector.git
synced 2025-09-29 22:30:02 -04:00
fix #81
This commit is contained in:
parent
14741ad521
commit
e913d7d4d4
@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package moe.yushi.authlibinjector.httpd;
|
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.empty;
|
||||||
import static java.util.Optional.of;
|
import static java.util.Optional.of;
|
||||||
import static java.util.Optional.ofNullable;
|
import static java.util.Optional.ofNullable;
|
||||||
@ -65,6 +66,10 @@ public class LegacySkinAPIFilter implements URLFilter {
|
|||||||
return empty();
|
return empty();
|
||||||
String username = matcher.group("username");
|
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;
|
Optional<String> skinUrl;
|
||||||
try {
|
try {
|
||||||
skinUrl = upstream.queryUUID(username)
|
skinUrl = upstream.queryUUID(username)
|
||||||
@ -104,4 +109,9 @@ public class LegacySkinAPIFilter implements URLFilter {
|
|||||||
.map(JsonUtils::asJsonString)
|
.map(JsonUtils::asJsonString)
|
||||||
.orElseThrow(() -> newUncheckedIOException("Invalid JSON: Missing texture url")));
|
.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;
|
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.BufferedInputStream;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@ -360,7 +359,7 @@ public abstract class NanoHTTPD {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a BufferedReader for parsing the header.
|
// 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
|
// Decode the header into parms and header java properties
|
||||||
Map<String, String> pre = new HashMap<>();
|
Map<String, String> pre = new HashMap<>();
|
||||||
@ -486,7 +485,7 @@ public abstract class NanoHTTPD {
|
|||||||
}
|
}
|
||||||
if (expect100Continue && !continueSent) {
|
if (expect100Continue && !continueSent) {
|
||||||
continueSent = true;
|
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;
|
return this.parsedInputStream;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user