Always use UTF-8 for reading TOML files (fixes #22)

This commit is contained in:
comp500
2022-05-11 17:45:39 +01:00
parent 07af6046c1
commit 92d6f68f1d
3 changed files with 7 additions and 8 deletions

View File

@@ -9,6 +9,7 @@ import link.infra.packwiz.installer.request.HandlerManager.getFileSource
import link.infra.packwiz.installer.request.HandlerManager.getNewLoc
import okio.Source
import okio.buffer
import java.io.InputStreamReader
import java.nio.file.Paths
class IndexFile {
@@ -43,7 +44,7 @@ class IndexFile {
linkedFileURI = getNewLoc(indexUri, file)
val src = getFileSource(linkedFileURI!!)
val fileStream = getHasher(hashFormat!!).getHashingSource(src)
linkedFile = Toml().read(fileStream.buffer().inputStream()).to(ModFile::class.java)
linkedFile = Toml().read(InputStreamReader(fileStream.buffer().inputStream(), "UTF-8")).to(ModFile::class.java)
if (!fileStream.hashIsEqual(fileHash)) {
throw Exception("Invalid mod file hash")
}