@@ -97,24 +97,26 @@ VarDecl getDeclIn(Variable v, Scope scope, string name, CandidateTopLevel tl) {
97
97
/**
98
98
* Tracks data flow from a string literal that may flow to a replace operation.
99
99
*/
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 ( ) )
102
104
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 ) )
104
106
}
105
107
106
108
/**
107
109
* Gets a string literal that flows to a replace operation.
108
110
*/
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 ( ) )
111
113
}
112
114
113
115
/**
114
116
* Holds if the string literal flows to a replace method call.
115
117
*/
116
118
predicate hasReplaceMethodCall ( CandidateStringLiteral lit ) {
117
- trackString ( lit ) .getAMethodCall ( ) instanceof StringReplaceCall
119
+ trackStringWithTemplateSyntax ( lit ) .getAMethodCall ( ) instanceof StringReplaceCall
118
120
}
119
121
120
122
from CandidateStringLiteral lit , Variable v , Scope s , string name , VarDecl decl
0 commit comments