Skip to content
Permalink
Browse files
FILEUPLOAD-312 - Use charset constant
  • Loading branch information
arturobernalg committed Apr 23, 2021
1 parent b825323 commit 149d38d7c1ff0e9f934774c7ad29eba0667d0d8a
Showing 2 changed files with 4 additions and 12 deletions.
@@ -19,7 +19,7 @@
import static java.lang.String.format;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -423,11 +423,7 @@ public byte[] getBoundary(final String contentType) {
return null;
}
byte[] boundary;
try {
boundary = boundaryStr.getBytes("ISO-8859-1");
} catch (final UnsupportedEncodingException e) {
boundary = boundaryStr.getBytes(); // Intentionally falls back to default charset
}
boundary = boundaryStr.getBytes(StandardCharsets.ISO_8859_1);
return boundary;
}

@@ -19,6 +19,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@@ -30,11 +31,6 @@
*/
public final class MimeUtility {

/**
* The {@code US-ASCII} charset identifier constant.
*/
private static final String US_ASCII_CHARSET = "US-ASCII";

/**
* The marker to indicate text is encoded with BASE64 algorithm.
*/
@@ -237,7 +233,7 @@ private static String decodeWord(final String word) throws ParseException, Unsup
// the decoder writes directly to an output stream.
final ByteArrayOutputStream out = new ByteArrayOutputStream(encodedText.length());

final byte[] encodedData = encodedText.getBytes(US_ASCII_CHARSET);
final byte[] encodedData = encodedText.getBytes(StandardCharsets.US_ASCII);

// Base64 encoded?
if (encoding.equals(BASE64_ENCODING_MARKER)) {

0 comments on commit 149d38d

Please sign in to comment.