From: Nick Burch Date: Tue, 1 Sep 2015 19:16:21 +0000 (+0000) Subject: Fix some Forbidden APIs errors X-Git-Tag: REL_3_13_FINAL~57 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2f4f7983b835b28ef930bbdb233c139d7fe8ff02;p=poi.git Fix some Forbidden APIs errors git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1700646 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/hssf/record/DConRefRecord.java b/src/java/org/apache/poi/hssf/record/DConRefRecord.java index deccff347b..bb9b52f1dc 100644 --- a/src/java/org/apache/poi/hssf/record/DConRefRecord.java +++ b/src/java/org/apache/poi/hssf/record/DConRefRecord.java @@ -18,10 +18,11 @@ */ package org.apache.poi.hssf.record; +import java.util.Arrays; + import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndianOutput; - -import java.util.Arrays; +import org.apache.poi.util.StringUtil; /** * DConRef records specify a range in a workbook (internal or external) that serves as a data source @@ -292,7 +293,7 @@ public class DConRefRecord extends StandardRecord { offset++; } - String out = new String(Arrays.copyOfRange(path, offset, path.length)); + String out = new String(Arrays.copyOfRange(path, offset, path.length), StringUtil.UTF8); //UNC paths have \u0003 chars as path separators. out = out.replaceAll("\u0003", "/"); return out; diff --git a/src/java/org/apache/poi/ss/format/CellElapsedFormatter.java b/src/java/org/apache/poi/ss/format/CellElapsedFormatter.java index 72a9a1fd1e..9a90e8a9e5 100644 --- a/src/java/org/apache/poi/ss/format/CellElapsedFormatter.java +++ b/src/java/org/apache/poi/ss/format/CellElapsedFormatter.java @@ -201,7 +201,7 @@ public class CellElapsedFormatter extends CellFormatter { parts[i] = specs.get(i).valueFor(elapsed); } - Formatter formatter = new Formatter(toAppendTo); + Formatter formatter = new Formatter(toAppendTo, Locale.ROOT); try { formatter.format(printfFmt, parts); } finally { diff --git a/src/java/org/apache/poi/util/StringUtil.java b/src/java/org/apache/poi/util/StringUtil.java index bd417961ea..ccf226f0fb 100644 --- a/src/java/org/apache/poi/util/StringUtil.java +++ b/src/java/org/apache/poi/util/StringUtil.java @@ -31,15 +31,12 @@ import org.apache.poi.hssf.record.RecordInputStream; * * Note - none of the methods in this class deals with {@link org.apache.poi.hssf.record.ContinueRecord}s. * For such functionality, consider using {@link RecordInputStream} - * - * - *@author Andrew C. Oliver - *@author Sergei Kozello (sergeikozello at mail.ru) - *@author Toshiaki Kamoshida (kamoshida.toshiaki at future dot co dot jp) */ public class StringUtil { - private static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1"); - private static final Charset UTF16LE = Charset.forName("UTF-16LE"); + protected static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1"); + protected static final Charset UTF16LE = Charset.forName("UTF-16LE"); + public static final Charset UTF8 = Charset.forName("UTF-8"); + private static Map msCodepointToUnicode; private StringUtil() {