diff --git a/core/src/main/java/lucee/commons/net/HTTPUtil.java b/core/src/main/java/lucee/commons/net/HTTPUtil.java index 87a3366af0..6fcc21a014 100755 --- a/core/src/main/java/lucee/commons/net/HTTPUtil.java +++ b/core/src/main/java/lucee/commons/net/HTTPUtil.java @@ -361,9 +361,10 @@ public static String escapeQSValue(String str, boolean encodeOnlyWhenNecessary) public static String escapePathValue(String str, boolean encodeOnlyWhenNecessary) { if (encodeOnlyWhenNecessary){ boolean hasPlus = str.indexOf('+') != -1; + boolean needsEncoding = ReqRspUtil.needEncoding(str, false); // in a path, space should be encoded as %20, URLEncoder.encode does this - if (!hasPlus && !ReqRspUtil.needEncoding(str, false)) return str; - return StringUtil.replace(str, "+", "%20", false); + if (!hasPlus && !needsEncoding) return str; + else if (hasPlus && !needsEncoding) return StringUtil.replace(str, "+", "%20", false); } PageContextImpl pc = (PageContextImpl) ThreadLocalPageContext.get();