Skip to content

Commit

Permalink
improve logic
Browse files Browse the repository at this point in the history
  • Loading branch information
zspitzer committed Dec 3, 2024
1 parent d3b5c42 commit 52b4880
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/src/main/java/lucee/commons/net/HTTPUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 52b4880

Please sign in to comment.