Skip to main content
Version: v1

XSS Protection

FoalTS provides some utils to protect you against XSS attacks.

escape(str: string): string

Escapes HTML and returns a new string.

escapeProp(object: object, propName: string): void

Escapes HTML in the given property.

escapeProp(myObject, 'foobar')

is equivalent to

myObject.foobar = escape(myObject.foobar)