diff --git a/Changelog.md b/Changelog.md
index 9bce73f..d3838f3 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -2,6 +2,12 @@
A brief description of what changes project contains
+## May 6, 2024
+
+#### v1.2.9
+
+- Fixed vulnerability issue related to strAttrs and children.
+
## April 23, 2024
#### v1.2.8
diff --git a/pom.xml b/pom.xml
index 3ff59ce..2b2b6aa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
com.contentstack.sdk
utils
- 1.2.8
+ 1.2.9
jar
Contentstack-utils
Java Utils SDK for Contentstack Content Delivery API, Contentstack is a headless CMS
diff --git a/src/main/java/com/contentstack/utils/render/DefaultOption.java b/src/main/java/com/contentstack/utils/render/DefaultOption.java
index e384698..35dae2a 100644
--- a/src/main/java/com/contentstack/utils/render/DefaultOption.java
+++ b/src/main/java/com/contentstack/utils/render/DefaultOption.java
@@ -6,6 +6,8 @@
import com.contentstack.utils.node.MarkType;
import org.apache.commons.text.StringEscapeUtils;
import org.json.JSONObject;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
import java.util.*;
@@ -101,67 +103,70 @@ private String escapeInjectHtml(JSONObject nodeObj, String nodeType) {
public String renderNode(String nodeType, JSONObject nodeObject, NodeCallback callback) {
String strAttrs = strAttrs(nodeObject);
String children = callback.renderChildren(nodeObject.optJSONArray("children"));
+ // Jsoup sanitization
+ Document sanitizedChildren = Jsoup.parse(children);
+ String cleanChildren = sanitizedChildren.body().html();
switch (nodeType) {
case "p":
- return "
" + children + "
";
+ return "" + cleanChildren + "
";
case "a":
- return "" + children + "";
+ return "" + cleanChildren + "";
case "img":
String assetLink = getNodeStr(nodeObject, "asset-link");
if (!assetLink.isEmpty()) {
JSONObject attrs = nodeObject.optJSONObject("attrs");
if (attrs.has("link")) {
- return "" + "
" + children + "";
+ return "" + "
" + cleanChildren + "";
}
- return "
" + children;
+ return "
" + cleanChildren;
}
- return "
" + children;
+ return "
" + cleanChildren;
case "embed":
- return "