Skip to content

Commit

Permalink
Replace use of Locale.ENGLISH with Locale.ROOT
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Aug 2, 2024
1 parent d1f579f commit 34722bf
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ The <action> type attribute can be add,update,fix,remove.
<release version="1.6.0" date="YYYY-MM-DD" description="1.6.0 Release, requires Java 8.">
<!-- ADD -->
<action dev="ggregory" type="add" due-to="mufasa1976, Jochen Wiedmann, Gary Gregory">[1.x] Enable multipart/related on FileUpload #314.</action>
<!-- FIX -->
<action type="fix" dev="ggregory" due-to="Gary Gregory">Replace use of Locale.ENGLISH with Locale.ROOT.</action>
<!-- UPDATE -->
<action dev="ggregory" type="update">Bump Java from 6 to 8.</action>
<action dev="ggregory" type="update">Bump commons-parent from 62 to 70.</action>
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/apache/commons/fileupload/FileUploadBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -718,7 +718,7 @@ private void parseHeaderLine(final FileItemHeadersImpl headers, final String hea
@Deprecated
protected final String getHeader(final Map<String, String> headers,
final String name) {
return headers.get(name.toLowerCase(Locale.ENGLISH));
return headers.get(name.toLowerCase(Locale.ROOT));
}

/**
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public Map<String, String> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> headerValueList = headerNameToValueListMap.get(nameLower);
if (null == headerValueList) {
return null;
Expand All @@ -62,7 +62,7 @@ public Iterator<String> getHeaderNames() {

@Override
public Iterator<String> getHeaders(final String name) {
final String nameLower = name.toLowerCase(Locale.ENGLISH);
final String nameLower = name.toLowerCase(Locale.ROOT);
List<String> headerValueList = headerNameToValueListMap.get(nameLower);
if (null == headerValueList) {
headerValueList = Collections.emptyList();
Expand All @@ -77,7 +77,7 @@ public Iterator<String> 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<String> headerValueList = headerNameToValueListMap.get(nameLower);
if (null == headerValueList) {
headerValueList = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 34722bf

Please sign in to comment.