From 52b4880e385556b34bbd2eb0e60880c6acb7a04d Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Tue, 3 Dec 2024 11:03:47 +0100 Subject: [PATCH] improve logic --- core/src/main/java/lucee/commons/net/HTTPUtil.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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();