Skip to content

Commit

Permalink
ZK-5598: CKEditor requests ExecutionImpl.encodeURL with null value, c…
Browse files Browse the repository at this point in the history
…auses NPE in embedded mode (zkoss#3094)

Co-authored-by: Jumper Chen <[email protected]>
  • Loading branch information
JamsonChan and jumperchen authored Dec 18, 2023
1 parent a1f09ca commit 6ba34ad
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions zk/src/main/java/org/zkoss/zk/ui/http/ExecutionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ public void setVoided(boolean voided) {
}

public String encodeURL(String uri) {
if (uri == null || uri.isEmpty()) // ZK-5598
return uri;
try {
String encodedURL = Encodes.encodeURL(_ctx, _request, _response, uri);
String zkHostURL = (String) getDesktop().getAttribute("org.zkoss.desktop.auHost");
Expand Down
1 change: 1 addition & 0 deletions zkdoc/release-note
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ZK 10.0.0
ZK-5522: CommonFns.formatNumber() doesn't handle null as javadoc mentions
ZK-5569: Radiogroup onCheck event type mismatch
ZK-5161: page directive's attributes are not encoded before rendering into HTML
ZK-5598: CKEditor requests ExecutionImpl.encodeURL with null value, causes NPE in embedded mode

* Upgrade Notes
+ Upgrade commons-fileupload to commons-fileupload2-javax 2.0.0-M1 and commons-io to 2.13.0 to support jakarta-friendly uploads
Expand Down
26 changes: 26 additions & 0 deletions zktest/src/main/webapp/test2/B100-ZK-5598.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!--
B100-ZK-5598.html
Purpose:
Description:
History:
Fri Dec 15 15:40:13 CST 2023, Created by jamson
Copyright (C) 2023 Potix Corporation. All Rights Reserved.
-->

<!DOCTYPE html>
<html>
<head>
<script src="http://localhost:8080/zktest/zkau/web/js/zkmax/embedded/index.js"></script>
</head>
<body>
<div>Set Library Property org.zkoss.web.servlet.http.embedded.enabled to true in zk.xml to enable embedded mode.</div>
<div>If you didn't see the ckeditor below, the bug still exist</div>
<div>(This bug triggered when use absolute-path to embedded a zul.</div>
<div id="zkapp"/>
<script>zEmbedded.load('zkapp', 'http://localhost:8080/zktest/test2/B100-ZK-5598.zul');</script>
</body>
</html>
16 changes: 16 additions & 0 deletions zktest/src/main/webapp/test2/B100-ZK-5598.zul
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
B100-ZK-5598.zul
Purpose:
Description:
History:
Fri Dec 15 15:40:05 CST 2023, Created by jamson
Copyright (C) 2023 Potix Corporation. All Rights Reserved.
-->
<zk>
<ckeditor value="To test this issue, you have to open B100-ZK-5598.html and follow the guides."/>
</zk>
1 change: 1 addition & 0 deletions zktest/src/main/webapp/test2/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3109,6 +3109,7 @@ B90-ZK-4431.zul=A,E,Multislider
##zats##B100-ZK-5522.zul=A,E,CommonFns,formatNumber
##zats##B100-ZK-5569.zul=A,E,Radiogroup,onCheck
##zats##B100-ZK-5161.zul=A,E,XSS,Security,Page
##Manually##B100-ZK-5598.zul=A,E,CKEditor,Embedded,NPE

##
# Features - 3.0.x version
Expand Down

0 comments on commit 6ba34ad

Please sign in to comment.