File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
javascript/ql/src/semmle/javascript Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -1603,17 +1603,26 @@ private predicate hasAllConstantLeafs(AddExpr add) {
1603
1603
private string getConcatenatedString ( Expr add ) {
1604
1604
result = getConcatenatedString ( add .getUnderlyingValue ( ) )
1605
1605
or
1606
- not add = getAnAddOperand ( any ( AddExpr parent | hasAllConstantLeafs ( parent ) ) ) and
1607
- hasAllConstantLeafs ( add ) and
1608
1606
result =
1609
1607
strictconcat ( Expr leaf |
1610
- leaf = getAnAddOperand * ( add )
1608
+ leaf = getAnAddOperand * ( add . ( SmallConcatRoot ) )
1611
1609
|
1612
1610
getConstantString ( leaf )
1613
1611
order by
1614
1612
leaf .getLocation ( ) .getStartLine ( ) , leaf .getLocation ( ) .getStartColumn ( )
1615
- ) and
1616
- result .length ( ) < 1000 * 1000
1613
+ )
1614
+ }
1615
+
1616
+ /**
1617
+ * An expr that is the root of a string concatenation of constant parts,
1618
+ * and the length of the resulting concatenation is less than 1 million chars.
1619
+ */
1620
+ private class SmallConcatRoot extends Expr {
1621
+ SmallConcatRoot ( ) {
1622
+ not this = getAnAddOperand ( any ( AddExpr parent | hasAllConstantLeafs ( parent ) ) ) and
1623
+ hasAllConstantLeafs ( this ) and
1624
+ sum ( Expr leaf | leaf = getAnAddOperand * ( this ) | getConstantString ( leaf ) .length ( ) ) < 1000 * 1000
1625
+ }
1617
1626
}
1618
1627
1619
1628
/**
You can’t perform that action at this time.
0 commit comments