This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 1.x
in repository https://gitbox.apache.org/repos/asf/commons-fileupload.git

commit 20daaa6d5651714698225df37a2cb9682d39c2d1
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Sep 15 23:04:02 2023 +0100

    Simplify String related calls
---
 src/main/java/org/apache/commons/fileupload/FileUploadBase.java   | 2 +-
 src/main/java/org/apache/commons/fileupload/ParameterParser.java  | 2 +-
 .../java/org/apache/commons/fileupload/util/mime/MimeUtility.java | 8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/fileupload/FileUploadBase.java 
b/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
index da2aa257..8ddaaa9b 100644
--- a/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
+++ b/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
@@ -625,7 +625,7 @@ public abstract class FileUploadBase {
                 }
                 // Continuation line found
                 end = parseEndOfLine(headerPart, nonWs);
-                header.append(" ").append(headerPart.substring(nonWs, end));
+                header.append(' ').append(headerPart, nonWs, end);
                 start = end + 2;
             }
             parseHeaderLine(headers, header.toString());
diff --git a/src/main/java/org/apache/commons/fileupload/ParameterParser.java 
b/src/main/java/org/apache/commons/fileupload/ParameterParser.java
index 4dd4b65e..af4dcfb6 100644
--- a/src/main/java/org/apache/commons/fileupload/ParameterParser.java
+++ b/src/main/java/org/apache/commons/fileupload/ParameterParser.java
@@ -326,7 +326,7 @@ public class ParameterParser {
             if (hasChar() && (charArray[pos] == separator)) {
                 pos++; // skip separator
             }
-            if ((paramName != null) && (paramName.length() > 0)) {
+            if ((paramName != null) && !paramName.isEmpty()) {
                 paramName = RFC2231Utility.stripDelimiter(paramName);
                 if (this.lowerCaseNames) {
                     paramName = paramName.toLowerCase(Locale.ENGLISH);
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 7bfef250..100cf4f0 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
@@ -99,7 +99,7 @@ public final class MimeUtility {
     public static String decodeText(final String text) throws 
UnsupportedEncodingException {
         // if the text contains any encoded tokens, those tokens will be 
marked with "=?".  If the
         // source string doesn't contain that sequent, no decoding is required.
-        if (text.indexOf(ENCODED_TOKEN_MARKER) < 0) {
+        if (!text.contains(ENCODED_TOKEN_MARKER)) {
             return text;
         }
 
@@ -154,7 +154,7 @@ public final class MimeUtility {
 
                         // are any whitespace characters significant?  Append 
'em if we've got 'em.
                         if (!previousTokenEncoded && startWhiteSpace != -1) {
-                            decodedText.append(text.substring(startWhiteSpace, 
endWhiteSpace));
+                            decodedText.append(text, startWhiteSpace, 
endWhiteSpace);
                             startWhiteSpace = -1;
                         }
                         // this is definitely a decoded token.
@@ -172,7 +172,7 @@ public final class MimeUtility {
                 // this is a normal token, so it doesn't matter what the 
previous token was.  Add the white space
                 // if we have it.
                 if (startWhiteSpace != -1) {
-                    decodedText.append(text.substring(startWhiteSpace, 
endWhiteSpace));
+                    decodedText.append(text, startWhiteSpace, endWhiteSpace);
                     startWhiteSpace = -1;
                 }
                 // this is not a decoded token.
@@ -229,7 +229,7 @@ public final class MimeUtility {
         final String encodedText = word.substring(encodingPos + 1, 
encodedTextPos);
 
         // seems a bit silly to encode a null string, but easy to deal with.
-        if (encodedText.length() == 0) {
+        if (encodedText.isEmpty()) {
             return "";
         }
 

Reply via email to