specify utf8 encoding
this should fix the following known bugs: - putting a U+2019 in the config causes it to become corrupted and ~double in size every launch - scripts become assembled incorrectly and the nbsp after your name in the chatbox becomes incorrect - the feed panel doesn't show emoji
This commit is contained in:
@@ -27,6 +27,7 @@ package net.runelite.http.service.feed;
|
||||
import com.google.common.hash.HashCode;
|
||||
import com.google.common.hash.Hasher;
|
||||
import com.google.common.hash.Hashing;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -66,7 +67,7 @@ public class FeedController
|
||||
Hasher hasher = Hashing.sha256().newHasher();
|
||||
for (FeedItem itemPrice : feedResult.getItems())
|
||||
{
|
||||
hasher.putBytes(itemPrice.getTitle().getBytes()).putBytes(itemPrice.getContent().getBytes());
|
||||
hasher.putBytes(itemPrice.getTitle().getBytes(StandardCharsets.UTF_8)).putBytes(itemPrice.getContent().getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
HashCode code = hasher.hash();
|
||||
hash = code.toString();
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
@@ -114,7 +115,7 @@ public class TwitterService
|
||||
{
|
||||
}.getType();
|
||||
List<TwitterStatusesResponseItem> statusesResponse = RuneLiteAPI.GSON
|
||||
.fromJson(new InputStreamReader(in), listType);
|
||||
.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), listType);
|
||||
|
||||
List<FeedItem> items = new ArrayList<>();
|
||||
|
||||
@@ -134,7 +135,7 @@ public class TwitterService
|
||||
|
||||
private void updateToken() throws IOException
|
||||
{
|
||||
String encodedCredentials = Base64.getEncoder().encodeToString(credentials.getBytes());
|
||||
String encodedCredentials = Base64.getEncoder().encodeToString(credentials.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(AUTH_URL)
|
||||
@@ -151,7 +152,7 @@ public class TwitterService
|
||||
|
||||
InputStream in = response.body().byteStream();
|
||||
TwitterOAuth2TokenResponse tokenResponse = RuneLiteAPI.GSON
|
||||
.fromJson(new InputStreamReader(in), TwitterOAuth2TokenResponse.class);
|
||||
.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), TwitterOAuth2TokenResponse.class);
|
||||
|
||||
if (!tokenResponse.getTokenType().equals("bearer"))
|
||||
{
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.google.gson.JsonParseException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@@ -297,7 +298,7 @@ public class ItemService
|
||||
}
|
||||
|
||||
InputStream in = response.body().byteStream();
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), clazz);
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), clazz);
|
||||
}
|
||||
catch (JsonParseException ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user