trivial: extracted constants
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/fileupload/trunk@1456977 13f79535-47bb-0310-9956-ffa450edef68
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 776423e..3b90027 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
@@ -31,6 +31,11 @@
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 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 @@
// 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 @@
// 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);
}