[jOOQ/jOOQ#9726] FilePattern matches too many files when wildcards are
being used
This commit is contained in:
parent
439238bd98
commit
7ab5709de4
@ -227,14 +227,20 @@ public final class FilePattern {
|
||||
loaded = true;
|
||||
}
|
||||
else {
|
||||
String prefix = pattern.replaceAll("[*?].*", "");
|
||||
file = new File(basedir, prefix).getAbsoluteFile();
|
||||
|
||||
// [#9726] The wildcard could be in the middle of a path segment, which
|
||||
// has to be ignored, e.g. the prefix of a/b*/c is a/
|
||||
String prefix = pattern.replaceAll("[^\\/]*?[*?].*", "");
|
||||
file = new File(prefix);
|
||||
|
||||
if (!file.isAbsolute())
|
||||
file = new File(basedir, prefix).getAbsoluteFile();
|
||||
|
||||
Pattern regex = Pattern.compile("^.*?"
|
||||
+ pattern
|
||||
.replace("\\", "/")
|
||||
.replace(".", "\\.")
|
||||
.replace("?", ".")
|
||||
.replace("?", "[^/]")
|
||||
.replace("**", ".+?")
|
||||
.replace("*", "[^/]*")
|
||||
+ "$"
|
||||
@ -285,6 +291,11 @@ public final class FilePattern {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* A callback interface that allows for loading a {@link Source}.
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user