summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorDavid Harrigan2013-08-18 13:26:28 (EDT)
committer Jan Bartel2013-08-21 17:47:10 (EDT)
commite351f040028d32382ca09f2a5187b07ae704a02f (patch)
treeaec3007d9f5ace1b8c39c6b0ba24008878d3d2bb
parent8951c4c773fb103528dc9e0f5ebfce4ddf47d870 (diff)
downloadorg.eclipse.jetty.project-e351f040028d32382ca09f2a5187b07ae704a02f.zip
org.eclipse.jetty.project-e351f040028d32382ca09f2a5187b07ae704a02f.tar.gz
org.eclipse.jetty.project-e351f040028d32382ca09f2a5187b07ae704a02f.tar.bz2
bug 415302
Patch to protect against null input's. -=david=- Signed-off-by: David Harrigan <dharrigan@gmail.com>
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizer.java30
1 files changed, 18 insertions, 12 deletions
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizer.java b/jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizer.java
index 0931f32..e41bdb3 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizer.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizer.java
@@ -334,12 +334,15 @@ public class QuotedStringTokenizer
/* ------------------------------------------------------------ */
/** Quote a string into an Appendable.
- * Only quotes and backslash are escaped.
+ * Only quotes and backslash are escaped.
* @param buffer The Appendable
* @param input The String to quote.
*/
public static void quoteOnly(Appendable buffer, String input)
{
+ if(input==null)
+ return;
+
try
{
buffer.append('"');
@@ -366,6 +369,9 @@ public class QuotedStringTokenizer
*/
public static void quote(Appendable buffer, String input)
{
+ if(input==null)
+ return;
+
try
{
buffer.append('"');
@@ -403,14 +409,14 @@ public class QuotedStringTokenizer
}
}
-
+
/* ------------------------------------------------------------ */
public static String unquoteOnly(String s)
{
return unquoteOnly(s, false);
}
-
-
+
+
/* ------------------------------------------------------------ */
/** Unquote a string, NOT converting unicode sequences
* @param s The string to unquote.
@@ -454,15 +460,15 @@ public class QuotedStringTokenizer
}
}
- return b.toString();
+ return b.toString();
}
-
+
/* ------------------------------------------------------------ */
public static String unquote(String s)
{
return unquote(s,false);
}
-
+
/* ------------------------------------------------------------ */
/** Unquote a string.
* @param s The string to unquote.
@@ -544,8 +550,8 @@ public class QuotedStringTokenizer
return b.toString();
}
-
-
+
+
/* ------------------------------------------------------------ */
/** Check that char c (which is preceded by a backslash) is a valid
* escape sequence.
@@ -554,8 +560,8 @@ public class QuotedStringTokenizer
*/
private static boolean isValidEscaping(char c)
{
- return ((c == 'n') || (c == 'r') || (c == 't') ||
- (c == 'f') || (c == 'b') || (c == '\\') ||
+ return ((c == 'n') || (c == 'r') || (c == 't') ||
+ (c == 'f') || (c == 'b') || (c == '\\') ||
(c == '/') || (c == '"') || (c == 'u'));
}
@@ -564,7 +570,7 @@ public class QuotedStringTokenizer
{
return s!=null && s.length()>0 && s.charAt(0)=='"' && s.charAt(s.length()-1)=='"';
}
-
+
/* ------------------------------------------------------------ */
/**
* @return handle double quotes if true