mirror of
https://github.com/github/codeql.git
synced 2025-12-21 19:26:31 +01:00
add a docstring, and rename rawString -> foldedString
This commit is contained in:
@@ -619,6 +619,10 @@ public class ASTExtractor {
|
|||||||
return '0' <= ch && ch <= '7';
|
return '0' <= ch && ch <= '7';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constant-folds simple string concatenations in `exp` while keeping an offset translation
|
||||||
|
* that tracks back to the original source.
|
||||||
|
*/
|
||||||
private Pair<String, OffsetTranslation> getStringConcatResult(Expression exp) {
|
private Pair<String, OffsetTranslation> getStringConcatResult(Expression exp) {
|
||||||
if (exp instanceof BinaryExpression) {
|
if (exp instanceof BinaryExpression) {
|
||||||
BinaryExpression be = (BinaryExpression) exp;
|
BinaryExpression be = (BinaryExpression) exp;
|
||||||
@@ -857,15 +861,15 @@ public class ASTExtractor {
|
|||||||
if (concatResult == null) {
|
if (concatResult == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String rawString = concatResult.fst();
|
String foldedString = concatResult.fst();
|
||||||
if (rawString.length() > 1000 && !rawString.trim().isEmpty()) {
|
if (foldedString.length() > 1000 && !foldedString.trim().isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
OffsetTranslation offsets = concatResult.snd();
|
OffsetTranslation offsets = concatResult.snd();
|
||||||
Position start = nd.getLoc().getStart();
|
Position start = nd.getLoc().getStart();
|
||||||
com.semmle.util.locations.Position startPos = new com.semmle.util.locations.Position(start.getLine(), start.getColumn(), start.getOffset());
|
com.semmle.util.locations.Position startPos = new com.semmle.util.locations.Position(start.getLine(), start.getColumn(), start.getOffset());
|
||||||
SourceMap sourceMap = SourceMap.legacyWithStartPos(SourceMap.fromString(nd.getLoc().getSource()).offsetBy(0, offsets), startPos);
|
SourceMap sourceMap = SourceMap.legacyWithStartPos(SourceMap.fromString(nd.getLoc().getSource()).offsetBy(0, offsets), startPos);
|
||||||
regexpExtractor.extract(rawString, sourceMap, nd, true);
|
regexpExtractor.extract(foldedString, sourceMap, nd, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user