Skip to content

Commit 5f7ae7a

Browse files
committed
HV-2057 Sonar: Address possible property path regex backtracking problem
1 parent f674c12 commit 5f7ae7a

File tree

1 file changed

+4
-4
lines changed
  • engine/src/main/java/org/hibernate/validator/internal/engine/path

1 file changed

+4
-4
lines changed

engine/src/main/java/org/hibernate/validator/internal/engine/path/PathImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ public final class PathImpl implements Path, Serializable {
4141
*
4242
* @see <a href="http://www.regexplanet.com/simple/index.jsp">Regular expression tester</a>
4343
*/
44-
private static final String LEADING_PROPERTY_GROUP = "[^\\[\\.]+"; // everything up to a [ or .
45-
private static final String OPTIONAL_INDEX_GROUP = "\\[(\\w*)\\]";
46-
private static final String REMAINING_PROPERTY_STRING = "\\.(.*)"; // processed recursively
44+
private static final String LEADING_PROPERTY_GROUP = "[^\\[\\.]++"; // everything up to a [ or .
45+
private static final String OPTIONAL_INDEX_GROUP = "\\[(\\w*+)\\]";
46+
private static final String REMAINING_PROPERTY_STRING = "\\.(.++)"; // processed recursively
4747

48-
private static final Pattern PATH_PATTERN = Pattern.compile( "(" + LEADING_PROPERTY_GROUP + ")(" + OPTIONAL_INDEX_GROUP + ")?(" + REMAINING_PROPERTY_STRING + ")*" );
48+
private static final Pattern PATH_PATTERN = Pattern.compile( "(" + LEADING_PROPERTY_GROUP + ")(" + OPTIONAL_INDEX_GROUP + ")?(" + REMAINING_PROPERTY_STRING + ")*+" );
4949
private static final int PROPERTY_NAME_GROUP = 1;
5050
private static final int INDEXED_GROUP = 2;
5151
private static final int INDEX_GROUP = 3;

0 commit comments

Comments
 (0)