@@ -28,6 +28,19 @@ module ReflectedXss {
2828 HttpResponseSink ( ) { not exists ( getAXssSafeHeaderDefinition ( this ) ) }
2929 }
3030
31+ /**
32+ * DEPRECATED: Gets a HeaderDefinition that defines a XSS safe content-type for `send`.
33+ */
34+ deprecated Http:: HeaderDefinition getANonHtmlHeaderDefinition ( Http:: ResponseSendArgument send ) {
35+ exists ( Http:: RouteHandler h |
36+ send .getRouteHandler ( ) = h and
37+ result = xssSafeContentTypeHeader ( h )
38+ |
39+ // The HeaderDefinition affects a response sent at `send`.
40+ headerAffects ( result , send )
41+ )
42+ }
43+
3144 /**
3245 * Gets a HeaderDefinition that defines a XSS safe content-type for `send`.
3346 */
@@ -42,7 +55,7 @@ module ReflectedXss {
4255 }
4356
4457 /**
45- * A content-type that may lead to javascript code being executed in the browser.
58+ * Gets a content-type that may lead to javascript code being executed in the browser.
4659 * ref: https://portswigger.net/web-security/cross-site-scripting/cheat-sheet#content-types
4760 */
4861 string xssUnsafeContentType ( ) {
@@ -54,6 +67,16 @@ module ReflectedXss {
5467 ]
5568 }
5669
70+ /**
71+ * DEPRECATED: Holds if `h` may send a response with a content type that is safe for XSS.
72+ */
73+ deprecated Http:: HeaderDefinition nonHtmlContentTypeHeader ( Http:: RouteHandler h ) {
74+ result = h .getAResponseHeader ( "content-type" ) and
75+ not exists ( string tp | result .defines ( "content-type" , tp ) |
76+ tp .toLowerCase ( ) .matches ( xssUnsafeContentType ( ) + "%" )
77+ )
78+ }
79+
5780 /**
5881 * Holds if `h` may send a response with a content type that is safe for XSS.
5982 */
0 commit comments