Skip to content

Commit

Permalink
feat: fix regular expresion to match Sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelAHM committed Dec 30, 2024
1 parent e86e482 commit f2ea4df
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class Ipv4Resource extends IpInterval<Ipv4Resource> implements Comp
public static final Ipv4Resource MAX_RANGE = new Ipv4Resource(MINIMUM_NUMBER, MAXIMUM_NUMBER);

private static final Splitter SPLIT_ON_DOT = Splitter.on('.');
private static final Pattern OCTET_PATTERN = Pattern.compile("^(?:[0-9]|[1-9][0-9]+)(?:-(?:[0-9]|[1-9][0-9]+)+)?$");
private static final Pattern OCTET_PATTERN = Pattern.compile("^(?:[1-9][0-9]*|0)(?:-[1-9][0-9]*|0)*$");

Check failure

Code scanning / CodeQL

Inefficient regular expression High

This part of the regular expression may cause exponential backtracking on strings starting with '0-1' and containing many repetitions of '0-1'.

private final int begin;
private final int end;
Expand Down

0 comments on commit f2ea4df

Please sign in to comment.