As seen, the requirements for secure
handling of an untrustworthy value
depend on the context in which the
value is used. The most commonly
encountered context is string interpolation
within the content of HTML
markup elements; here, simple
HTML-escaping suffices to prevent
XSS bugs. Several special contexts,
however, apply to various DOM elements
and within certain kinds of
markup, where embedded strings are
interpreted as URLs, Cascading Style
Sheets (CSS) expressions, or JavaScript
code. To avoid XSS bugs, each of
these contexts requires specific validation
or escaping, or a combination
of the two.2,5 The accompanying sidebar,
“A Subtle XSS Bug,” shows this
can be quite tricky to get right.
As seen, the requirements for securehandling of an untrustworthy valuedepend on the context in which thevalue is used. The most commonlyencountered context is string interpolationwithin the content of HTMLmarkup elements; here, simpleHTML-escaping suffices to preventXSS bugs. Several special contexts,however, apply to various DOM elementsand within certain kinds ofmarkup, where embedded strings areinterpreted as URLs, Cascading StyleSheets (CSS) expressions, or JavaScriptcode. To avoid XSS bugs, each ofthese contexts requires specific validationor escaping, or a combinationof the two.2,5 The accompanying sidebar,“A Subtle XSS Bug,” shows thiscan be quite tricky to get right.
การแปล กรุณารอสักครู่..
