Skip to content

Commit

Permalink
ZK-5766: DomPurify fails with partial html content
Browse files Browse the repository at this point in the history
  • Loading branch information
jumperchen authored and DevChu committed Aug 16, 2024
1 parent fac6ce0 commit 6204ecd
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 5 deletions.
8 changes: 4 additions & 4 deletions zk/src/main/resources/web/js/zk/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3163,9 +3163,9 @@ new zul.wnd.Window({
if ((tempHtml = this.domStyle_(no)))
outHtml += ' style="' + tempHtml + '"';
if ((tempHtml = this.domClass_(no)))
outHtml += ' class="' + /*safe*/ zUtl.encodeXMLAttribute(tempHtml) + '"';
outHtml += ' class="' + /*safe*/ zUtl.encodeXML(tempHtml) + '"';
if ((tempHtml = this.domTooltiptext_()))
outHtml += ' title="' + /*safe*/ zUtl.encodeXMLAttribute(tempHtml) + '"'; // ZK-676
outHtml += ' title="' + /*safe*/ zUtl.encodeXML(tempHtml) + '"'; // ZK-676
if ((tabIndexHtml = /*safe*/ this.getTabindex()) != undefined)
outHtml += ' tabindex="' + tabIndexHtml + '"';
} else {
Expand All @@ -3174,9 +3174,9 @@ new zul.wnd.Window({
if (!no.domStyle && (tempHtml = this.domStyle_(no)))
outHtml += ' style="' + tempHtml + '"';
if (!no.domClass && (tempHtml = this.domClass_(no)))
outHtml += ' class="' + /*safe*/ zUtl.encodeXMLAttribute(tempHtml) + '"';
outHtml += ' class="' + /*safe*/ zUtl.encodeXML(tempHtml) + '"';
if (!no.tooltiptext && (tempHtml = this.domTooltiptext_()))
outHtml += ' title="' + /*safe*/ zUtl.encodeXMLAttribute(tempHtml) + '"'; // ZK-676
outHtml += ' title="' + /*safe*/ zUtl.encodeXML(tempHtml) + '"'; // ZK-676
if (!no.tabindex && (tabIndexHtml = /*safe*/ this.getTabindex()) != undefined)
outHtml += ' tabindex="' + tabIndexHtml + '"';
}
Expand Down
3 changes: 2 additions & 1 deletion zkdoc/release-note
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ ZK 10.1.0
* Features

* Bugs
ZK-5764: Unable to call original method when using custom ViewModelAnnotationResolver
ZK-5764: Unable to call original method when using custom ViewModelAnnotationResolver
ZK-5766: DomPurify fails with partial html content

* Upgrade Notes

Expand Down
32 changes: 32 additions & 0 deletions zktest/src/main/webapp/test2/B101-ZK-5766.zul
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
B101-ZK-5766.zul
Purpose:
Description:
History:
2024/8/15, Created by jumperchen
Copyright (C) 2024 Potix Corporation. All Rights Reserved.
-->
<zk>
<div>
<zscript>
<![CDATA[
String anotherTooltip = "TEST <a test>...</a> should display in tooltip";
String anotherTooltip2 = "TEST <a href>...</a> should display in tooltip";
]]>
</zscript>

<a tooltiptext="${anotherTooltip}" label="Click here for XSS"/>
<button sclass="${anotherTooltip2}" label="Click here for XSS"/>

<div tooltiptext="${anotherTooltip}">looks ok but</div>
<div tooltiptext="${anotherTooltip2}">this causes a problem</div>
<window title="click here for xss" sclass="${anotherTooltip2}"></window>
</div>
</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 @@ -3127,6 +3127,7 @@ B90-ZK-4431.zul=A,E,Multislider

## B101
##zats##B101-ZK-5764.zul=A,E,MVVM,Annotation,Method
##zats##B101-ZK-5766.zul=A,E,XSS,Security

##
# Features - 3.0.x version
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* B101_ZK_5766Test.java
Purpose:
Description:
History:
5:06 PM 2024/8/15, Created by jumperchen
Copyright (C) 2024 Potix Corporation. All Rights Reserved.
*/
package org.zkoss.zktest.zats.test2;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

import org.zkoss.test.webdriver.WebDriverTestCase;

/**
* @author jumperchen
*/
public class B101_ZK_5766Test extends WebDriverTestCase {

@Test
public void test() {
connect();
assertEquals(0, jq("div>:contains(\"should display in tooltip\")").length());
}
}

0 comments on commit 6204ecd

Please sign in to comment.