
regexcompiler.RegexSymbol Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of regex-static-analysis Show documentation
Show all versions of regex-static-analysis Show documentation
A tool to perform static analysis on regexes to determine whether they are vulnerable to ReDoS.
package regexcompiler;
public class RegexSymbol extends RegexSubexpression {
public RegexSymbol(String subexpressionContent, int index) {
super(subexpressionContent, index);
}
@Override
public SubexpressionType getSubexpressionType() {
return SubexpressionType.SYMBOL;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (char c : getSubexpressionContent().toCharArray()) {
if ('!' <= c && c <= '~') {
sb.append(c);
} else {
sb.append(String.format("\\x{%02x}", (int) c));
}
}
return sb.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy