@@ -97,24 +97,26 @@ VarDecl getDeclIn(Variable v, Scope scope, string name, CandidateTopLevel tl) {
9797/**
9898 * Tracks data flow from a string literal that may flow to a replace operation.
9999 */
100- DataFlow:: SourceNode trackString ( CandidateStringLiteral lit , DataFlow:: TypeTracker t ) {
101- t .start ( ) and result = lit .flow ( )
100+ DataFlow:: SourceNode trackStringWithTemplateSyntax (
101+ CandidateStringLiteral lit , DataFlow:: TypeTracker t
102+ ) {
103+ t .start ( ) and result = lit .flow ( ) and exists ( lit .getAReferencedVariable ( ) )
102104 or
103- exists ( DataFlow:: TypeTracker t2 | result = trackString ( lit , t2 ) .track ( t2 , t ) )
105+ exists ( DataFlow:: TypeTracker t2 | result = trackStringWithTemplateSyntax ( lit , t2 ) .track ( t2 , t ) )
104106}
105107
106108/**
107109 * Gets a string literal that flows to a replace operation.
108110 */
109- DataFlow:: SourceNode trackString ( CandidateStringLiteral lit ) {
110- result = trackString ( lit , DataFlow:: TypeTracker:: end ( ) )
111+ DataFlow:: SourceNode trackStringWithTemplateSyntax ( CandidateStringLiteral lit ) {
112+ result = trackStringWithTemplateSyntax ( lit , DataFlow:: TypeTracker:: end ( ) )
111113}
112114
113115/**
114116 * Holds if the string literal flows to a replace method call.
115117 */
116118predicate hasReplaceMethodCall ( CandidateStringLiteral lit ) {
117- trackString ( lit ) .getAMethodCall ( ) instanceof StringReplaceCall
119+ trackStringWithTemplateSyntax ( lit ) .getAMethodCall ( ) instanceof StringReplaceCall
118120}
119121
120122from CandidateStringLiteral lit , Variable v , Scope s , string name , VarDecl decl
0 commit comments