From 4fb681d0096f7f5694b4440da71343b1acb4d6f3 Mon Sep 17 00:00:00 2001 From: mguessan Date: Sat, 13 Aug 2011 21:22:45 +0000 Subject: [PATCH] EWS: Allow null value in StringUtil.decodeUrlcompname git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1775 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- src/java/davmail/util/StringUtil.java | 60 ++++++++++++++------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/src/java/davmail/util/StringUtil.java b/src/java/davmail/util/StringUtil.java index d16827e5..be414ae8 100644 --- a/src/java/davmail/util/StringUtil.java +++ b/src/java/davmail/util/StringUtil.java @@ -225,10 +225,10 @@ public final class StringUtil { if (result.indexOf('"') >= 0) { result = QUOTE_PATTERN.matcher(result).replaceAll("""); } - if (result.indexOf('\r') >=0) { + if (result.indexOf('\r') >= 0) { result = CR_PATTERN.matcher(result).replaceAll(" "); } - if (result.indexOf('\n') >=0) { + if (result.indexOf('\n') >= 0) { result = LF_PATTERN.matcher(result).replaceAll(" "); } } @@ -330,33 +330,35 @@ public final class StringUtil { */ public static String decodeUrlcompname(String urlcompname) { String result = urlcompname; - if (result.indexOf((char) 0xF8FF) >= 0) { - result = URLENCODED_F8FF_PATTERN.matcher(result).replaceAll("_xF8FF_"); - } - if (result.indexOf("%26") >= 0) { - result = URLENCODED_AMP_PATTERN.matcher(result).replaceAll("&"); - } - if (result.indexOf("%2B") >= 0) { - result = URLENCODED_PLUS_PATTERN.matcher(result).replaceAll("+"); - } - if (result.indexOf("%3A") >= 0) { - result = URLENCODED_COLON_PATTERN.matcher(result).replaceAll(":"); - } - if (result.indexOf("%3C") >= 0) { - result = URLENCODED_LT_PATTERN.matcher(result).replaceAll("<"); - } - if (result.indexOf("%3E") >= 0) { - result = URLENCODED_GT_PATTERN.matcher(result).replaceAll(">"); - } - if (result.indexOf("%22") >= 0) { - result = URLENCODED_QUOTE_PATTERN.matcher(result).replaceAll("\""); - } - // CRLF is replaced with LF in response - if (result.indexOf('\n') >= 0) { - result = URLENCODED_X0D0A_PATTERN.matcher(result).replaceAll("_x000D__x000A_"); - } - if (result.indexOf("%25") >= 0) { - result = URLENCODED_PERCENT_PATTERN.matcher(result).replaceAll("%"); + if (result != null) { + if (result.indexOf((char) 0xF8FF) >= 0) { + result = URLENCODED_F8FF_PATTERN.matcher(result).replaceAll("_xF8FF_"); + } + if (result.indexOf("%26") >= 0) { + result = URLENCODED_AMP_PATTERN.matcher(result).replaceAll("&"); + } + if (result.indexOf("%2B") >= 0) { + result = URLENCODED_PLUS_PATTERN.matcher(result).replaceAll("+"); + } + if (result.indexOf("%3A") >= 0) { + result = URLENCODED_COLON_PATTERN.matcher(result).replaceAll(":"); + } + if (result.indexOf("%3C") >= 0) { + result = URLENCODED_LT_PATTERN.matcher(result).replaceAll("<"); + } + if (result.indexOf("%3E") >= 0) { + result = URLENCODED_GT_PATTERN.matcher(result).replaceAll(">"); + } + if (result.indexOf("%22") >= 0) { + result = URLENCODED_QUOTE_PATTERN.matcher(result).replaceAll("\""); + } + // CRLF is replaced with LF in response + if (result.indexOf('\n') >= 0) { + result = URLENCODED_X0D0A_PATTERN.matcher(result).replaceAll("_x000D__x000A_"); + } + if (result.indexOf("%25") >= 0) { + result = URLENCODED_PERCENT_PATTERN.matcher(result).replaceAll("%"); + } } return result; }