@@ -619,6 +619,10 @@ private boolean isOctalDigit(char ch) {
619
619
return '0' <= ch && ch <= '7' ;
620
620
}
621
621
622
+ /**
623
+ * Constant-folds simple string concatenations in `exp` while keeping an offset translation
624
+ * that tracks back to the original source.
625
+ */
622
626
private Pair <String , OffsetTranslation > getStringConcatResult (Expression exp ) {
623
627
if (exp instanceof BinaryExpression ) {
624
628
BinaryExpression be = (BinaryExpression ) exp ;
@@ -857,15 +861,15 @@ private void extractRegxpFromBinop(BinaryExpression nd, Context c) {
857
861
if (concatResult == null ) {
858
862
return ;
859
863
}
860
- String rawString = concatResult .fst ();
861
- if (rawString .length () > 1000 && !rawString .trim ().isEmpty ()) {
864
+ String foldedString = concatResult .fst ();
865
+ if (foldedString .length () > 1000 && !foldedString .trim ().isEmpty ()) {
862
866
return ;
863
867
}
864
868
OffsetTranslation offsets = concatResult .snd ();
865
869
Position start = nd .getLoc ().getStart ();
866
870
com .semmle .util .locations .Position startPos = new com .semmle .util .locations .Position (start .getLine (), start .getColumn (), start .getOffset ());
867
871
SourceMap sourceMap = SourceMap .legacyWithStartPos (SourceMap .fromString (nd .getLoc ().getSource ()).offsetBy (0 , offsets ), startPos );
868
- regexpExtractor .extract (rawString , sourceMap , nd , true );
872
+ regexpExtractor .extract (foldedString , sourceMap , nd , true );
869
873
return ;
870
874
}
871
875
0 commit comments