CoverityFix CID:1350851 Dubious method used 99/20399/3
Nimish Kapoor [Tue, 31 Jul 2018 16:50:26 +0000 (21:50 +0530)]
Found a call to a method which will perform a byte to String (or String
to byte) conversion, and will assume that the default platform encoding
is suitable. This will cause the application behaviour to vary between
platforms. Use an alternative API and specify a charset name or Charset
object explicitly.
https://stackoverflow.com/questions/696626/java-filereader-encoding-issue

Change-Id: Ie85f6d40fe84c6eb4af1ff8b6bca375ff9949cf3

scilab/modules/helptools/src/java/org/scilab/modules/helptools/image/LaTeXImageConverter.java

index 3312108..4e5439b 100644 (file)
@@ -19,6 +19,8 @@ import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.FileInputStream;
 import java.util.Map;
 
 import org.scilab.forge.jlatexmath.TeXConstants;
@@ -94,7 +96,7 @@ public class LaTeXImageConverter implements ExternalImageConverter {
         StringBuilder buffer = new StringBuilder();
         boolean ok = false;
         try {
-            input = new BufferedReader(new FileReader(latex));
+            input = new BufferedReader(new InputStreamReader(new FileInputStream(latex), "UTF-8"));
             String line = null;
             while ((line = input.readLine()) != null) {
                 buffer.append(line);