feat: make HTML attribute sanitization stricter (#8977)
* feat: make HTML attribute sanitization stricter * fix double escapepull/8979/head
parent
c84babf574
commit
b63689c230
@ -1,13 +1,19 @@
|
||||
import * as utils from "../utils";
|
||||
import { isTransparent, sanitizeHTMLAttribute } from "../utils";
|
||||
|
||||
describe("Test isTransparent", () => {
|
||||
it("should return true when color is rgb transparent", () => {
|
||||
expect(utils.isTransparent("#ff00")).toEqual(true);
|
||||
expect(utils.isTransparent("#fff00000")).toEqual(true);
|
||||
expect(utils.isTransparent("transparent")).toEqual(true);
|
||||
expect(isTransparent("#ff00")).toEqual(true);
|
||||
expect(isTransparent("#fff00000")).toEqual(true);
|
||||
expect(isTransparent("transparent")).toEqual(true);
|
||||
});
|
||||
|
||||
it("should return false when color is not transparent", () => {
|
||||
expect(utils.isTransparent("#ced4da")).toEqual(false);
|
||||
expect(isTransparent("#ced4da")).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("sanitizeHTMLAttribute()", () => {
|
||||
it("should escape HTML attribute special characters & not double escape", () => {
|
||||
expect(sanitizeHTMLAttribute(`&"'><`)).toBe("&"'><");
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue