Skip to content

Commit

Permalink
fix cross-site scripting vulnerability
Browse files Browse the repository at this point in the history
  • Loading branch information
jumperchen committed Aug 23, 2024
1 parent 846b22d commit 1aa5d8f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions zk/src/main/java/org/zkoss/zk/ui/http/WpdExtendlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ protected byte[] retrieve(HttpServletRequest request, HttpServletResponse respon
boolean pkgStart = path.endsWith("0.wpd");
boolean pkgEnd = path.endsWith("$.wpd");
int lastPartIndex = path.lastIndexOf("/") + 1;
String lastPart = path.substring(lastPartIndex);
String lastPart = Encode.forJavaScript(path.substring(lastPartIndex));
String pkgName = lastPart.replaceAll("[\\d]{1,2}\\.wpd", "");
if (pkgStart || pkgEnd) {
if (pkgStart) {
Expand Down Expand Up @@ -780,7 +780,7 @@ private static String outMain(String main, Map<String, String[]> params) {
}
}

sb.append(JSONObject.toJSONString(ms)).append(")\n})");
sb.append(Encode.forJavaScript(JSONObject.toJSONString(ms))).append(")\n})");
return sb.toString();
}

Expand Down Expand Up @@ -1063,7 +1063,7 @@ private byte[] processDynamicWpdWithSourceMapIfAny(HttpServletRequest request, H
} catch (javax.servlet.ServletException ex) {
throw new UiException(ex);
}
sb.append(scriptVariableName).append(".src='").append(url).append("';");
sb.append(scriptVariableName).append(".src='").append(Encode.forJavaScript(url)).append("';");
sb.append("\ndocument.getElementsByTagName('head')[0].appendChild(").append(scriptVariableName).append(");");
lastWpd = dividedPath.substring(dividedPath.lastIndexOf("/") + 1);
}
Expand Down

0 comments on commit 1aa5d8f

Please sign in to comment.