Avoid infinite loop in PatternMatchUtils
Issue: SPR-12971
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,6 +50,9 @@ public abstract class PatternMatchUtils {
|
||||
return str.endsWith(pattern.substring(1));
|
||||
}
|
||||
String part = pattern.substring(1, nextIndex);
|
||||
if ("".equals(part)) {
|
||||
return simpleMatch(pattern.substring(nextIndex), str);
|
||||
}
|
||||
int partIndex = str.indexOf(part);
|
||||
while (partIndex != -1) {
|
||||
if (simpleMatch(pattern.substring(nextIndex), str.substring(partIndex + part.length()))) {
|
||||
@@ -74,8 +77,8 @@ public abstract class PatternMatchUtils {
|
||||
*/
|
||||
public static boolean simpleMatch(String[] patterns, String str) {
|
||||
if (patterns != null) {
|
||||
for (int i = 0; i < patterns.length; i++) {
|
||||
if (simpleMatch(patterns[i], str)) {
|
||||
for (String pattern : patterns) {
|
||||
if (simpleMatch(pattern, str)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user