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:
@@ -33,6 +33,7 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.Comparator;
|
||||
@@ -103,7 +104,7 @@ public class FlatStorage implements Storage
|
||||
for (Index idx : store.getIndexes())
|
||||
{
|
||||
String file = idx.getId() + EXTENSION;
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(openReader(file))))
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(openReader(file), StandardCharsets.UTF_8)))
|
||||
{
|
||||
int lineNo = 0;
|
||||
Archive archive = null;
|
||||
@@ -213,7 +214,7 @@ public class FlatStorage implements Storage
|
||||
for (Index idx : store.getIndexes())
|
||||
{
|
||||
String file = idx.getId() + EXTENSION;
|
||||
try (PrintStream br = new PrintStream(openWriter(file)))
|
||||
try (PrintStream br = new PrintStream(openWriter(file), false, StandardCharsets.UTF_8.name()))
|
||||
{
|
||||
br.printf("protocol=%d\n", idx.getProtocol());
|
||||
br.printf("revision=%d\n", idx.getRevision());
|
||||
|
||||
@@ -26,8 +26,8 @@ package net.runelite.cache.io;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public final class OutputStream extends java.io.OutputStream
|
||||
{
|
||||
@@ -181,16 +181,7 @@ public final class OutputStream extends java.io.OutputStream
|
||||
|
||||
public void writeString(String str)
|
||||
{
|
||||
byte[] b;
|
||||
try
|
||||
{
|
||||
b = str.getBytes("ISO-8859-1");
|
||||
}
|
||||
catch (UnsupportedEncodingException ex)
|
||||
{
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
writeBytes(b);
|
||||
writeBytes(str.getBytes(StandardCharsets.ISO_8859_1));
|
||||
writeByte(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ package net.runelite.cache.script.assembler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import net.runelite.cache.definitions.ScriptDefinition;
|
||||
import net.runelite.cache.script.Instructions;
|
||||
import net.runelite.cache.script.assembler.rs2asmParser.ProgContext;
|
||||
@@ -45,7 +47,7 @@ public class Assembler
|
||||
public ScriptDefinition assemble(InputStream in) throws IOException
|
||||
{
|
||||
// Get our lexer
|
||||
rs2asmLexer lexer = new rs2asmLexer(new ANTLRInputStream(in));
|
||||
rs2asmLexer lexer = new rs2asmLexer(new ANTLRInputStream(new InputStreamReader(in, StandardCharsets.UTF_8)));
|
||||
|
||||
LexerErrorListener errorListener = new LexerErrorListener();
|
||||
lexer.addErrorListener(errorListener);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
package net.runelite.cache.script.assembler;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import net.runelite.cache.definitions.ScriptDefinition;
|
||||
import net.runelite.cache.script.Instructions;
|
||||
import net.runelite.cache.script.disassembler.Disassembler;
|
||||
@@ -76,7 +77,7 @@ public class AssemblerTest
|
||||
in = AssemblerTest.class.getResourceAsStream(this.script);
|
||||
Assert.assertNotNull(in);
|
||||
|
||||
String original = new String(IOUtils.toByteArray(in)).replaceAll("\r\n", "\n");
|
||||
String original = new String(IOUtils.toByteArray(in), StandardCharsets.UTF_8).replaceAll("\r\n", "\n");
|
||||
|
||||
logger.info(original);
|
||||
logger.info("-----------------------");
|
||||
|
||||
@@ -27,6 +27,7 @@ package net.runelite.cache.script.disassembler;
|
||||
import com.google.common.io.Files;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import net.runelite.cache.IndexType;
|
||||
import net.runelite.cache.StoreLocation;
|
||||
import net.runelite.cache.definitions.ScriptDefinition;
|
||||
@@ -78,7 +79,7 @@ public class DisassemblerTest
|
||||
Disassembler disassembler = new Disassembler();
|
||||
String out = disassembler.disassemble(script);
|
||||
|
||||
Files.write(out.getBytes(), outFile);
|
||||
Files.write(out.getBytes(StandardCharsets.UTF_8), outFile);
|
||||
|
||||
++count;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
package net.runelite.cache.util;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -32,7 +33,7 @@ public class XteaTest
|
||||
@Test
|
||||
public void test()
|
||||
{
|
||||
byte[] data = "testtesttest1".getBytes();
|
||||
byte[] data = "testtesttest1".getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
int[] key = new int[]
|
||||
{
|
||||
|
||||
@@ -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.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -66,7 +67,7 @@ public class AccountClient
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
InputStream in = response.body().byteStream();
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), OAuthResponse.class);
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), OAuthResponse.class);
|
||||
}
|
||||
catch (JsonParseException ex)
|
||||
{
|
||||
|
||||
@@ -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 lombok.AllArgsConstructor;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
import okhttp3.HttpUrl;
|
||||
@@ -170,7 +171,7 @@ public class ChatClient
|
||||
}
|
||||
|
||||
InputStream in = response.body().byteStream();
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), Task.class);
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), Task.class);
|
||||
}
|
||||
catch (JsonParseException ex)
|
||||
{
|
||||
@@ -307,7 +308,7 @@ public class ChatClient
|
||||
}
|
||||
|
||||
InputStream in = response.body().byteStream();
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), Duels.class);
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), Duels.class);
|
||||
}
|
||||
catch (JsonParseException ex)
|
||||
{
|
||||
@@ -354,7 +355,7 @@ public class ChatClient
|
||||
}
|
||||
|
||||
InputStream in = response.body().byteStream();
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), LayoutRoom[].class);
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), LayoutRoom[].class);
|
||||
}
|
||||
catch (JsonParseException ex)
|
||||
{
|
||||
|
||||
@@ -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.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -67,7 +68,7 @@ public class ConfigClient
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
InputStream in = response.body().byteStream();
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), Configuration.class);
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), Configuration.class);
|
||||
}
|
||||
catch (JsonParseException ex)
|
||||
{
|
||||
|
||||
@@ -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 lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
@@ -63,7 +64,7 @@ public class FeedClient
|
||||
}
|
||||
|
||||
InputStream in = response.body().byteStream();
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), FeedResult.class);
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), FeedResult.class);
|
||||
}
|
||||
catch (JsonParseException ex)
|
||||
{
|
||||
|
||||
@@ -30,6 +30,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.Map;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -68,7 +69,7 @@ public class ItemClient
|
||||
}
|
||||
|
||||
InputStream in = response.body().byteStream();
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), ItemPrice[].class);
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), ItemPrice[].class);
|
||||
}
|
||||
catch (JsonParseException ex)
|
||||
{
|
||||
@@ -103,7 +104,7 @@ public class ItemClient
|
||||
final Type typeToken = new TypeToken<Map<Integer, ItemStats>>()
|
||||
{
|
||||
}.getType();
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), typeToken);
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), typeToken);
|
||||
}
|
||||
catch (JsonParseException ex)
|
||||
{
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.google.gson.reflect.TypeToken;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -117,7 +118,7 @@ public class LootTrackerClient
|
||||
}
|
||||
|
||||
InputStream in = response.body().byteStream();
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), new TypeToken<List<LootAggregate>>()
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), new TypeToken<List<LootAggregate>>()
|
||||
{
|
||||
}.getType());
|
||||
}
|
||||
|
||||
@@ -30,6 +30,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.Map;
|
||||
import lombok.Value;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -71,7 +72,7 @@ public class NpcInfoClient
|
||||
final Type typeToken = new TypeToken<Map<Integer, NpcInfo>>()
|
||||
{
|
||||
}.getType();
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), typeToken);
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), typeToken);
|
||||
}
|
||||
catch (JsonParseException ex)
|
||||
{
|
||||
|
||||
@@ -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 lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
@@ -64,7 +65,7 @@ public class OSBGrandExchangeClient
|
||||
}
|
||||
|
||||
final InputStream in = response.body().byteStream();
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), OSBGrandExchangeResult.class);
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), OSBGrandExchangeResult.class);
|
||||
}
|
||||
catch (JsonParseException ex)
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.google.gson.JsonParseException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
@@ -64,7 +65,7 @@ public class WorldClient
|
||||
}
|
||||
|
||||
InputStream in = response.body().byteStream();
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), WorldResult.class);
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), WorldResult.class);
|
||||
}
|
||||
catch (JsonParseException ex)
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.google.gson.reflect.TypeToken;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -103,7 +104,7 @@ public class XteaClient
|
||||
{
|
||||
InputStream in = response.body().byteStream();
|
||||
// CHECKSTYLE:OFF
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), new TypeToken<List<XteaKey>>() { }.getType());
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), new TypeToken<List<XteaKey>>() { }.getType());
|
||||
// CHECKSTYLE:ON
|
||||
}
|
||||
catch (JsonParseException ex)
|
||||
@@ -126,7 +127,7 @@ public class XteaClient
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
InputStream in = response.body().byteStream();
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), XteaKey.class);
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), XteaKey.class);
|
||||
}
|
||||
catch (JsonParseException ex)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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.util.UUID;
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
@@ -58,7 +59,7 @@ class SessionClient
|
||||
ResponseBody body = response.body();
|
||||
|
||||
InputStream in = body.byteStream();
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), UUID.class);
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), UUID.class);
|
||||
}
|
||||
catch (JsonParseException | IllegalArgumentException ex) // UUID.fromString can throw IllegalArgumentException
|
||||
{
|
||||
|
||||
@@ -27,9 +27,12 @@ package net.runelite.client.account;
|
||||
import com.google.gson.Gson;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
import javax.inject.Inject;
|
||||
@@ -91,7 +94,7 @@ public class SessionManager
|
||||
|
||||
try (FileInputStream in = new FileInputStream(sessionFile))
|
||||
{
|
||||
session = new Gson().fromJson(new InputStreamReader(in), AccountSession.class);
|
||||
session = new Gson().fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), AccountSession.class);
|
||||
|
||||
log.debug("Loaded session for {}", session.getUsername());
|
||||
}
|
||||
@@ -119,7 +122,7 @@ public class SessionManager
|
||||
return;
|
||||
}
|
||||
|
||||
try (FileWriter fw = new FileWriter(sessionFile))
|
||||
try (Writer fw = new OutputStreamWriter(new FileOutputStream(sessionFile), StandardCharsets.UTF_8))
|
||||
{
|
||||
new Gson().toJson(accountSession, fw);
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ import java.io.OutputStreamWriter;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.AtomicMoveNotSupportedException;
|
||||
import java.nio.file.Files;
|
||||
@@ -224,7 +223,7 @@ public class ConfigManager
|
||||
final Properties properties = new Properties();
|
||||
try (FileInputStream in = new FileInputStream(propertiesFile))
|
||||
{
|
||||
properties.load(new InputStreamReader(in, Charset.forName("UTF-8")));
|
||||
properties.load(new InputStreamReader(in, StandardCharsets.UTF_8));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -295,7 +294,7 @@ public class ConfigManager
|
||||
|
||||
try (FileInputStream in = new FileInputStream(propertiesFile))
|
||||
{
|
||||
properties.load(new InputStreamReader(in, Charset.forName("UTF-8")));
|
||||
properties.load(new InputStreamReader(in, StandardCharsets.UTF_8));
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
@@ -53,7 +54,7 @@ public class ItemVariationMapping
|
||||
};
|
||||
|
||||
final InputStream geLimitData = ItemVariationMapping.class.getResourceAsStream("/item_variations.json");
|
||||
final Map<String, Collection<Integer>> itemVariations = gson.fromJson(new InputStreamReader(geLimitData), typeToken.getType());
|
||||
final Map<String, Collection<Integer>> itemVariations = gson.fromJson(new InputStreamReader(geLimitData, StandardCharsets.UTF_8), typeToken.getType());
|
||||
|
||||
ImmutableMap.Builder<Integer, Integer> builder = new ImmutableMap.Builder<>();
|
||||
ImmutableMultimap.Builder<Integer, Integer> invertedBuilder = new ImmutableMultimap.Builder<>();
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
package net.runelite.client.plugins.gpu;
|
||||
|
||||
import com.jogamp.opengl.GL4;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
class GLUtil
|
||||
{
|
||||
@@ -63,14 +64,14 @@ class GLUtil
|
||||
{
|
||||
byte[] err = new byte[ERR_LEN];
|
||||
gl.glGetShaderInfoLog(shader, ERR_LEN, buf, 0, err, 0);
|
||||
return new String(err, 0, buf[0]);
|
||||
return new String(err, 0, buf[0], StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
static String glGetProgramInfoLog(GL4 gl, int program)
|
||||
{
|
||||
byte[] err = new byte[ERR_LEN];
|
||||
gl.glGetProgramInfoLog(program, ERR_LEN, buf, 0, err, 0);
|
||||
return new String(err, 0, buf[0]);
|
||||
return new String(err, 0, buf[0], StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
static int glGenVertexArrays(GL4 gl)
|
||||
|
||||
@@ -24,10 +24,13 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.gpu.template;
|
||||
|
||||
import com.google.common.io.CharStreams;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Template
|
||||
@@ -92,7 +95,13 @@ public class Template
|
||||
|
||||
private static String inputStreamToString(InputStream in)
|
||||
{
|
||||
Scanner scanner = new Scanner(in).useDelimiter("\\A");
|
||||
return scanner.next();
|
||||
try
|
||||
{
|
||||
return CharStreams.toString(new InputStreamReader(in, StandardCharsets.UTF_8));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ package net.runelite.client.plugins.skillcalculator;
|
||||
import com.google.gson.Gson;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.runelite.client.plugins.skillcalculator.beans.SkillData;
|
||||
@@ -43,7 +44,7 @@ class CacheSkillData
|
||||
}
|
||||
|
||||
InputStream skillDataFile = SkillCalculatorPlugin.class.getResourceAsStream(dataFile);
|
||||
SkillData skillData = new Gson().fromJson(new InputStreamReader(skillDataFile), SkillData.class);
|
||||
SkillData skillData = new Gson().fromJson(new InputStreamReader(skillDataFile, StandardCharsets.UTF_8), SkillData.class);
|
||||
|
||||
cache.put(dataFile, skillData);
|
||||
return skillData;
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -88,7 +89,7 @@ class Skybox
|
||||
|
||||
public Skybox(InputStream is, String filename) throws IOException
|
||||
{
|
||||
this(new InputStreamReader(is), filename);
|
||||
this(new InputStreamReader(is, StandardCharsets.UTF_8), filename);
|
||||
}
|
||||
|
||||
public Skybox(Reader reader, String filename) throws IOException
|
||||
|
||||
@@ -26,6 +26,7 @@ package net.runelite.client.plugins.twitch;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.inject.Provides;
|
||||
import java.io.IOException;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Map;
|
||||
import javax.inject.Inject;
|
||||
@@ -218,8 +219,15 @@ public class TwitchPlugin extends Plugin implements TwitchListener, ChatboxInput
|
||||
return true;
|
||||
}
|
||||
|
||||
twitchIRCClient.privmsg(message);
|
||||
addChatMessage(twitchConfig.username(), message);
|
||||
try
|
||||
{
|
||||
twitchIRCClient.privmsg(message);
|
||||
addChatMessage(twitchConfig.username(), message);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
log.warn("failed to send message", e);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -27,8 +27,10 @@ package net.runelite.client.plugins.twitch.irc;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import javax.net.SocketFactory;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -48,7 +50,7 @@ public class TwitchIRCClient extends Thread implements AutoCloseable
|
||||
|
||||
private Socket socket;
|
||||
private BufferedReader in;
|
||||
private PrintWriter out;
|
||||
private Writer out;
|
||||
private long last;
|
||||
private boolean pingSent;
|
||||
|
||||
@@ -86,8 +88,8 @@ public class TwitchIRCClient extends Thread implements AutoCloseable
|
||||
socket = socketFactory.createSocket(HOST, PORT);
|
||||
socket.setSoTimeout(READ_TIMEOUT);
|
||||
|
||||
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
out = new PrintWriter(socket.getOutputStream());
|
||||
in = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8));
|
||||
out = new OutputStreamWriter(socket.getOutputStream(), StandardCharsets.UTF_8);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
@@ -95,11 +97,11 @@ public class TwitchIRCClient extends Thread implements AutoCloseable
|
||||
return;
|
||||
}
|
||||
|
||||
register(username, password);
|
||||
join(channel);
|
||||
|
||||
try
|
||||
{
|
||||
register(username, password);
|
||||
join(channel);
|
||||
|
||||
String line;
|
||||
|
||||
while ((line = read()) != null)
|
||||
@@ -162,8 +164,16 @@ public class TwitchIRCClient extends Thread implements AutoCloseable
|
||||
|
||||
if (!pingSent && System.currentTimeMillis() - last >= PING_TIMEOUT)
|
||||
{
|
||||
ping("twitch");
|
||||
pingSent = true;
|
||||
try
|
||||
{
|
||||
ping("twitch");
|
||||
pingSent = true;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
log.debug("Ping failure, disconnecting.", e);
|
||||
close();
|
||||
}
|
||||
}
|
||||
else if (pingSent)
|
||||
{
|
||||
@@ -172,29 +182,29 @@ public class TwitchIRCClient extends Thread implements AutoCloseable
|
||||
}
|
||||
}
|
||||
|
||||
private void register(String username, String oauth)
|
||||
private void register(String username, String oauth) throws IOException
|
||||
{
|
||||
send("CAP", "REQ", "twitch.tv/commands twitch.tv/tags");
|
||||
send("PASS", oauth);
|
||||
send("NICK", username);
|
||||
}
|
||||
|
||||
private void join(String channel)
|
||||
private void join(String channel) throws IOException
|
||||
{
|
||||
send("JOIN", channel);
|
||||
}
|
||||
|
||||
private void ping(String destination)
|
||||
private void ping(String destination) throws IOException
|
||||
{
|
||||
send("PING", destination);
|
||||
}
|
||||
|
||||
public void privmsg(String message)
|
||||
public void privmsg(String message) throws IOException
|
||||
{
|
||||
send("PRIVMSG", channel, message);
|
||||
}
|
||||
|
||||
private void send(String command, String... args)
|
||||
private void send(String command, String... args) throws IOException
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(command);
|
||||
|
||||
@@ -28,6 +28,7 @@ package net.runelite.client.rs;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import lombok.AllArgsConstructor;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
@@ -55,7 +56,7 @@ class ClientConfigLoader
|
||||
}
|
||||
|
||||
String str;
|
||||
final BufferedReader in = new BufferedReader(new InputStreamReader(response.body().byteStream()));
|
||||
final BufferedReader in = new BufferedReader(new InputStreamReader(response.body().byteStream(), StandardCharsets.UTF_8));
|
||||
while ((str = in.readLine()) != null)
|
||||
{
|
||||
int idx = str.indexOf('=');
|
||||
|
||||
@@ -35,6 +35,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -215,7 +216,7 @@ public class ImageCapture
|
||||
try (InputStream in = response.body().byteStream())
|
||||
{
|
||||
ImageUploadResponse imageUploadResponse = RuneLiteAPI.GSON
|
||||
.fromJson(new InputStreamReader(in), ImageUploadResponse.class);
|
||||
.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), ImageUploadResponse.class);
|
||||
|
||||
if (imageUploadResponse.isSuccess())
|
||||
{
|
||||
|
||||
@@ -27,6 +27,7 @@ package net.runelite.client.plugins.discord;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import javax.inject.Inject;
|
||||
@@ -72,7 +73,7 @@ public class DiscordStateTest
|
||||
public void before()
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
when(partyService.getLocalPartyId()).thenReturn(UUID.nameUUIDFromBytes("test".getBytes()));
|
||||
when(partyService.getLocalPartyId()).thenReturn(UUID.nameUUIDFromBytes("test".getBytes(StandardCharsets.UTF_8)));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user