Re-added URL Encoding to Paste

This commit is contained in:
Auxilor
2021-11-16 09:30:20 +00:00
parent 89c529fdb3
commit 68ae25b7db

View File

@@ -10,6 +10,8 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.function.Consumer;
@@ -42,7 +44,7 @@ public class Paste {
public void getHastebinToken(@NotNull final Consumer<String> callback) {
Eco.getHandler().getEcoPlugin().getScheduler().runAsync(() -> {
try {
byte[] postData = contents.getBytes(StandardCharsets.UTF_8);
byte[] postData = URLEncoder.encode(contents, StandardCharsets.UTF_8).getBytes(StandardCharsets.UTF_8);
int postDataLength = postData.length;
String requestURL = "https://paste.willfp.com/documents";
@@ -94,7 +96,7 @@ public class Paste {
result.append(line);
}
}
return new Paste(result.toString());
return new Paste(URLDecoder.decode(result.toString(), StandardCharsets.UTF_8));
} catch (IOException e) {
e.printStackTrace();
}