All Downloads are FREE. Search and download functionalities are using the official Maven repository.

regexcompiler.RegexSymbol Maven / Gradle / Ivy

Go to download

A tool to perform static analysis on regexes to determine whether they are vulnerable to ReDoS.

There is a newer version: 1.0.8
Show newest version
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