diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 25c1efc432..b7ead35a4b 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -46,6 +46,8 @@ The type attribute can be add,update,fix,remove. [1.x] Enable multipart/related on FileUpload #314. + + Replace use of Locale.ENGLISH with Locale.ROOT. Bump Java from 6 to 8. Bump commons-parent from 62 to 70. diff --git a/src/main/java/org/apache/commons/fileupload/FileUploadBase.java b/src/main/java/org/apache/commons/fileupload/FileUploadBase.java index 7de61e0408..035480ba58 100644 --- a/src/main/java/org/apache/commons/fileupload/FileUploadBase.java +++ b/src/main/java/org/apache/commons/fileupload/FileUploadBase.java @@ -75,7 +75,7 @@ public static final boolean isMultipartContent(final RequestContext ctx) { if (contentType == null) { return false; } - return contentType.toLowerCase(Locale.ENGLISH).startsWith(MULTIPART); + return contentType.toLowerCase(Locale.ROOT).startsWith(MULTIPART); } /** @@ -489,7 +489,7 @@ protected String getFileName(final FileItemHeaders headers) { private String getFileName(final String pContentDisposition) { String fileName = null; if (pContentDisposition != null) { - final String cdl = pContentDisposition.toLowerCase(Locale.ENGLISH); + final String cdl = pContentDisposition.toLowerCase(Locale.ROOT); if (cdl.startsWith(FORM_DATA) || cdl.startsWith(ATTACHMENT)) { final ParameterParser parser = new ParameterParser(); parser.setLowerCaseNames(true); @@ -532,7 +532,7 @@ protected String getFieldName(final FileItemHeaders headers) { private String getFieldName(final String pContentDisposition) { String fieldName = null; if (pContentDisposition != null - && pContentDisposition.toLowerCase(Locale.ENGLISH).startsWith(FORM_DATA)) { + && pContentDisposition.toLowerCase(Locale.ROOT).startsWith(FORM_DATA)) { final ParameterParser parser = new ParameterParser(); parser.setLowerCaseNames(true); // Parameter parser can handle null input @@ -718,7 +718,7 @@ private void parseHeaderLine(final FileItemHeadersImpl headers, final String hea @Deprecated protected final String getHeader(final Map headers, final String name) { - return headers.get(name.toLowerCase(Locale.ENGLISH)); + return headers.get(name.toLowerCase(Locale.ROOT)); } /** @@ -970,13 +970,13 @@ public void setHeaders(final FileItemHeaders pHeaders) { final String contentType = ctx.getContentType(); if (null == contentType - || !contentType.toLowerCase(Locale.ENGLISH).startsWith(MULTIPART)) { + || !contentType.toLowerCase(Locale.ROOT).startsWith(MULTIPART)) { throw new InvalidContentTypeException( format("the request neither contains a %s nor a %s nor a %s stream, content type header is %s", MULTIPART_FORM_DATA, MULTIPART_MIXED, MULTIPART_RELATED, contentType)); } - multipartRelated = contentType.toLowerCase(Locale.ENGLISH).startsWith(MULTIPART_RELATED); + multipartRelated = contentType.toLowerCase(Locale.ROOT).startsWith(MULTIPART_RELATED); @SuppressWarnings("deprecation") // still has to be backward compatible final int contentLengthInt = ctx.getContentLength(); @@ -1084,7 +1084,7 @@ private boolean findNextItem() throws IOException { if (fieldName != null) { final String subContentType = headers.getHeader(CONTENT_TYPE); if (subContentType != null - && subContentType.toLowerCase(Locale.ENGLISH) + && subContentType.toLowerCase(Locale.ROOT) .startsWith(MULTIPART_MIXED)) { currentFieldName = fieldName; // Multiple files associated with this field name diff --git a/src/main/java/org/apache/commons/fileupload/ParameterParser.java b/src/main/java/org/apache/commons/fileupload/ParameterParser.java index 4ce5275a2c..2e93aacb20 100644 --- a/src/main/java/org/apache/commons/fileupload/ParameterParser.java +++ b/src/main/java/org/apache/commons/fileupload/ParameterParser.java @@ -329,7 +329,7 @@ public Map parse( if (paramName != null && !paramName.isEmpty()) { paramName = RFC2231Utility.stripDelimiter(paramName); if (this.lowerCaseNames) { - paramName = paramName.toLowerCase(Locale.ENGLISH); + paramName = paramName.toLowerCase(Locale.ROOT); } params.put(paramName, paramValue); } diff --git a/src/main/java/org/apache/commons/fileupload/util/FileItemHeadersImpl.java b/src/main/java/org/apache/commons/fileupload/util/FileItemHeadersImpl.java index bf6067f7d1..ad504d043b 100644 --- a/src/main/java/org/apache/commons/fileupload/util/FileItemHeadersImpl.java +++ b/src/main/java/org/apache/commons/fileupload/util/FileItemHeadersImpl.java @@ -47,7 +47,7 @@ public class FileItemHeadersImpl implements FileItemHeaders, Serializable { @Override public String getHeader(final String name) { - final String nameLower = name.toLowerCase(Locale.ENGLISH); + final String nameLower = name.toLowerCase(Locale.ROOT); final List headerValueList = headerNameToValueListMap.get(nameLower); if (null == headerValueList) { return null; @@ -62,7 +62,7 @@ public Iterator getHeaderNames() { @Override public Iterator getHeaders(final String name) { - final String nameLower = name.toLowerCase(Locale.ENGLISH); + final String nameLower = name.toLowerCase(Locale.ROOT); List headerValueList = headerNameToValueListMap.get(nameLower); if (null == headerValueList) { headerValueList = Collections.emptyList(); @@ -77,7 +77,7 @@ public Iterator getHeaders(final String name) { * @param value value of this header */ public synchronized void addHeader(final String name, final String value) { - final String nameLower = name.toLowerCase(Locale.ENGLISH); + final String nameLower = name.toLowerCase(Locale.ROOT); List headerValueList = headerNameToValueListMap.get(nameLower); if (null == headerValueList) { headerValueList = new ArrayList<>(); diff --git a/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java b/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java index d0378a3537..a4edb5c345 100644 --- a/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java +++ b/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java @@ -210,7 +210,7 @@ private static String decodeWord(final String word) throws ParseException, Unsup } // pull out the character set information (this is the MIME name at this point). - final String charset = word.substring(2, charsetPos).toLowerCase(Locale.ENGLISH); + final String charset = word.substring(2, charsetPos).toLowerCase(Locale.ROOT); // now pull out the encoding token the same way. final int encodingPos = word.indexOf('?', charsetPos + 1); @@ -269,7 +269,7 @@ private static String javaCharset(final String charset) { return null; } - final String mappedCharset = MIME2JAVA.get(charset.toLowerCase(Locale.ENGLISH)); + final String mappedCharset = MIME2JAVA.get(charset.toLowerCase(Locale.ROOT)); // if there is no mapping, then the original name is used. Many of the MIME character set // names map directly back into Java. The reverse isn't necessarily true. if (mappedCharset == null) {