feat: add escapeHtml function
This can be used to escape any special characters in a string with HTML before sending from the server back to the client. This is important to prevent a cross-site scripting attack.
This commit is contained in:
@ -445,3 +445,11 @@ describe("onLine", () => {
|
||||
expect(await received).toEqual(expected)
|
||||
})
|
||||
})
|
||||
|
||||
describe("escapeHtml", () => {
|
||||
it("should escape HTML", () => {
|
||||
expect(util.escapeHtml(`<div class="error">"Hello & world"</div>`)).toBe(
|
||||
"<div class="error">"Hello & world"</div>",
|
||||
)
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user