Browse Source

Fix a handful of forbidden apis identified problems

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1698198 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_3_13_FINAL
Nick Burch 8 years ago
parent
commit
5f05589bb7

+ 8
- 7
src/java/org/apache/poi/ss/format/CellDateFormatter.java View File

@@ -23,6 +23,7 @@ import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Formatter;
import java.util.Locale;
import java.util.regex.Matcher;

/**
@@ -69,22 +70,22 @@ public class CellDateFormatter extends CellFormatter {
desc.setCharAt(mStart + i, 'm');
mStart = -1;
}
return part.toLowerCase();
return part.toLowerCase(Locale.ROOT);

case 'h':
case 'H':
mStart = -1;
hStart = pos;
hLen = part.length();
return part.toLowerCase();
return part.toLowerCase(Locale.ROOT);

case 'd':
case 'D':
mStart = -1;
if (part.length() <= 2)
return part.toLowerCase();
return part.toLowerCase(Locale.ROOT);
else
return part.toLowerCase().replace('d', 'E');
return part.toLowerCase(Locale.ROOT).replace('d', 'E');

case 'm':
case 'M':
@@ -92,16 +93,16 @@ public class CellDateFormatter extends CellFormatter {
mLen = part.length();
// For 'm' after 'h', output minutes ('m') not month ('M')
if (hStart >= 0)
return part.toLowerCase();
return part.toLowerCase(Locale.ROOT);
else
return part.toUpperCase();
return part.toUpperCase(Locale.ROOT);

case 'y':
case 'Y':
mStart = -1;
if (part.length() == 3)
part = "yyyy";
return part.toLowerCase();
return part.toLowerCase(Locale.ROOT);

case '0':
mStart = -1;

+ 2
- 1
src/java/org/apache/poi/ss/format/CellTextFormatter.java View File

@@ -18,6 +18,7 @@ package org.apache.poi.ss.format;

import org.apache.poi.ss.format.CellFormatPart.PartHandler;

import java.util.Locale;
import java.util.regex.Matcher;

/**
@@ -62,7 +63,7 @@ public class CellTextFormatter extends CellFormatter {
int start = toAppendTo.length();
String text = obj.toString();
if (obj instanceof Boolean) {
text = text.toUpperCase();
text = text.toUpperCase(Locale.ROOT);
}
toAppendTo.append(desc);
for (int i = 0; i < textPos.length; i++) {

+ 6
- 2
src/java/org/apache/poi/util/HexDump.java View File

@@ -25,8 +25,11 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.nio.charset.Charset;
import java.text.DecimalFormat;

import org.apache.commons.codec.CharEncoding;

/**
* dump data in hexadecimal format; derived from a HexDump utility I
* wrote in June 2001.
@@ -36,6 +39,7 @@ import java.text.DecimalFormat;
*/
public class HexDump {
public static final String EOL = System.getProperty("line.separator");
private static final Charset UTF8 = Charset.forName(CharEncoding.UTF_8);
private static final char _hexcodes[] = "0123456789ABCDEF".toCharArray();
private static final int _shifts[] =
{
@@ -70,7 +74,7 @@ public class HexDump {
{
if (data.length == 0)
{
stream.write( ("No Data" + EOL).getBytes() );
stream.write( ("No Data" + EOL).getBytes(UTF8) );
stream.flush();
return;
}
@@ -125,7 +129,7 @@ public class HexDump {
}
}
buffer.append(EOL);
stream.write(buffer.toString().getBytes());
stream.write(buffer.toString().getBytes(UTF8));
stream.flush();
buffer.setLength(0);
display_offset += chars_read;

Loading…
Cancel
Save