@@ -4830,6 +4830,35 @@ module StdlibPrivate {
48304830 override predicate isShellInterpreted ( DataFlow:: Node arg ) { arg = this .getCommand ( ) }
48314831 }
48324832 }
4833+
4834+ // ---------------------------------------------------------------------------
4835+ // html
4836+ // ---------------------------------------------------------------------------
4837+ /**
4838+ * A call to 'html.escape'.
4839+ * See https://docs.python.org/3/library/html.html#html.escape
4840+ */
4841+ private class HtmlEscapeCall extends Escaping:: Range , API:: CallNode {
4842+ HtmlEscapeCall ( ) {
4843+ this = API:: moduleImport ( "html" ) .getMember ( "escape" ) .getACall ( ) and
4844+ // if quote escaping is disabled, that might lead to XSS if the result is inserted
4845+ // in the attribute value of a tag, such as `<foo bar="escape_result">`. Since we
4846+ // don't know how values are being inserted, and we don't want to lose these
4847+ // results (FNs), we require quote escaping to be enabled. This might lead to some
4848+ // FPs, so we might need to revisit this in the future.
4849+ not this .getParameter ( 1 , "quote" )
4850+ .getAValueReachingSink ( )
4851+ .asExpr ( )
4852+ .( ImmutableLiteral )
4853+ .booleanValue ( ) = false
4854+ }
4855+
4856+ override DataFlow:: Node getAnInput ( ) { result = this .getParameter ( 0 , "s" ) .asSink ( ) }
4857+
4858+ override DataFlow:: Node getOutput ( ) { result = this }
4859+
4860+ override string getKind ( ) { result = Escaping:: getHtmlKind ( ) }
4861+ }
48334862}
48344863
48354864// ---------------------------------------------------------------------------
0 commit comments