@@ -28,6 +28,19 @@ module ReflectedXss {
28
28
HttpResponseSink ( ) { not exists ( getAXssSafeHeaderDefinition ( this ) ) }
29
29
}
30
30
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
+
31
44
/**
32
45
* Gets a HeaderDefinition that defines a XSS safe content-type for `send`.
33
46
*/
@@ -42,7 +55,7 @@ module ReflectedXss {
42
55
}
43
56
44
57
/**
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.
46
59
* ref: https://portswigger.net/web-security/cross-site-scripting/cheat-sheet#content-types
47
60
*/
48
61
string xssUnsafeContentType ( ) {
@@ -54,6 +67,16 @@ module ReflectedXss {
54
67
]
55
68
}
56
69
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
+
57
80
/**
58
81
* Holds if `h` may send a response with a content type that is safe for XSS.
59
82
*/
0 commit comments