mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-19 04:45:07 -04:00
Potential fix
This commit is contained in:
parent
17c6e10846
commit
bef28abf6f
2 changed files with 8 additions and 12 deletions
|
@ -227,7 +227,7 @@ public final class DissectParser {
|
|||
// jump to the end of the match
|
||||
i += lookAheadMatches;
|
||||
// look for consecutive delimiters (e.g. a,,,,d,e)
|
||||
while (i < input.length) {
|
||||
while (dissectPair.key.skipRightPadding() && i < input.length) {
|
||||
lookAheadMatches = 0;
|
||||
for (int j = 0; j < delimiter.length; j++) {
|
||||
if (i + j < input.length && input[i + j] == delimiter[j]) {
|
||||
|
@ -238,16 +238,6 @@ public final class DissectParser {
|
|||
if (lookAheadMatches == delimiter.length) {
|
||||
// jump to the end of the match
|
||||
i += lookAheadMatches;
|
||||
if (key.skipRightPadding() == false) {
|
||||
// progress the keys/delimiter if possible
|
||||
if (it.hasNext() == false) {
|
||||
break; // the while loop
|
||||
}
|
||||
dissectPair = it.next();
|
||||
key = dissectPair.key();
|
||||
// add the key with an empty value for the empty delimiter
|
||||
dissectMatch.add(key, "");
|
||||
}
|
||||
} else {
|
||||
break; // the while loop
|
||||
}
|
||||
|
|
|
@ -316,7 +316,7 @@ public class DissectParserTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testAppendWithConsecutiveDelimiters() {
|
||||
assertMatch("%{+a/1},%{+a/3}-%{+a/2} %{b}", "foo,bar----baz lol", Arrays.asList("a", "b"), Arrays.asList("foobar", ""));
|
||||
assertMatch("%{+a/1},%{+a/3}-%{+a/2} %{b}", "foo,bar----baz lol", Arrays.asList("a", "b"), Arrays.asList("foo---bazbar", "lol"));
|
||||
assertMatch("%{+a/1},%{+a/3->}-%{+a/2} %{b}", "foo,bar----baz lol", Arrays.asList("a", "b"), Arrays.asList("foobazbar", "lol"));
|
||||
}
|
||||
|
||||
|
@ -476,6 +476,12 @@ public class DissectParserTests extends ESTestCase {
|
|||
assertThat(new DissectParser("%{a} %{b} %{*c} %{&c} %{*d} %{&d}", "").referenceKeys(), contains("c", "d"));
|
||||
}
|
||||
|
||||
// Test for elasticsearch#119264
|
||||
public void testConcurrentDelimitersAdditional() {
|
||||
assertMatch("%{a}-%{b}", "foo------bar", Arrays.asList("a", "b"), Arrays.asList("foo", "-----bar"));
|
||||
assertMatch("%{}|%{}|foo=%{field}", "||foo=bar", Arrays.asList("field"), Arrays.asList("bar"));
|
||||
}
|
||||
|
||||
private DissectException assertFail(String pattern, String input) {
|
||||
return expectThrows(DissectException.class, () -> new DissectParser(pattern, null).forceParse(input));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue