You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2013/03/15 15:56:20 UTC

svn commit: r1456977 - /commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java

Author: simonetripodi
Date: Fri Mar 15 14:56:20 2013
New Revision: 1456977

URL: http://svn.apache.org/r1456977
Log:
trivial: extracted constants

Modified:
    commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java

Modified: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java?rev=1456977&r1=1456976&r2=1456977&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java (original)
+++ commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java Fri Mar 15 14:56:20 2013
@@ -31,6 +31,11 @@ import java.util.Map;
 public final class MimeUtility {
 
     /**
+     * If the text contains any encoded tokens, those tokens will be marked with "=?"
+     */
+    private static final String ENCODED_TOKEN_MARKER = "=?";
+
+    /**
      * The linear whitespace chars sequence.
      */
     private static final String LINEAR_WHITESPACE = " \t\r\n";
@@ -74,7 +79,7 @@ public final class MimeUtility {
     public static String decodeText(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("=?") < 0) {
+        if (text.indexOf(ENCODED_TOKEN_MARKER) < 0) {
             return text;
         }
 
@@ -124,7 +129,7 @@ public final class MimeUtility {
                 // pull out the word token.
                 String word = text.substring(wordStart, offset);
                 // is the token encoded?  decode the word
-                if (word.startsWith("=?")) {
+                if (word.startsWith(ENCODED_TOKEN_MARKER)) {
                     try {
                         // if this gives a parsing failure, treat it like a non-encoded word.
                         String decodedWord = decodeWord(word);
@@ -177,7 +182,7 @@ public final class MimeUtility {
         // encoded words start with the characters "=?".  If this not an encoded word, we throw a
         // ParseException for the caller.
 
-        if (!word.startsWith("=?")) {
+        if (!word.startsWith(ENCODED_TOKEN_MARKER)) {
             throw new ParseException("Invalid RFC 2047 encoded-word: " + word);
         }