diff --git a/spec/cdata_spec.js b/spec/cdata_spec.js
index 3742edfe..93fea6b8 100644
--- a/spec/cdata_spec.js
+++ b/spec/cdata_spec.js
@@ -462,4 +462,22 @@ patronymic`;
// console.log(JSON.stringify(result,null,4));
expect(result).toEqual(expected);
});
+
+ it("should neutralize CDATA delimiters when building so a value cannot break out (GHSA-gh4j-gqv2-49f6)", function() {
+ const payload = "a]]> s.replace(//g, "");
+
+ const out1 = new XMLBuilder({ cdataPropName: "#cdata", format: false })
+ .build({ data: { "#cdata": payload } });
+ expect(XMLValidator.validate("" + out1 + "")).toBe(true);
+ expect(stripCData(out1)).not.toContain("/g, "");
+
+ const out1 = new XMLBuilder({ commentPropName: "#comment", format: false })
+ .build({ note: { "#comment": payload } });
+ expect(XMLValidator.validate("" + out1 + "")).toBe(true);
+ expect(stripComments(out1)).not.toContain("