Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Dissect with leading non-ascii characters #111184

Merged
merged 4 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/111184.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 111184
summary: Fix Dissect with leading non-ascii characters
area: Ingest Node
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public Map<String, String> parse(String inputString) {
DissectKey key = dissectPair.key();
byte[] delimiter = dissectPair.delimiter().getBytes(StandardCharsets.UTF_8);
// start dissection after the first delimiter
int i = leadingDelimiter.length();
int i = leadingDelimiter.getBytes(StandardCharsets.UTF_8).length;
int valueStart = i;
int lookAheadMatches;
// start walking the input string byte by byte, look ahead for matches where needed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,18 @@ public void testMatchUnicode() {
assertMatch("%{a->}࿏%{b}", "⟳༒࿏࿏࿏࿏࿏༒⟲", Arrays.asList("a", "b"), Arrays.asList("⟳༒", "༒⟲"));
assertMatch("%{*a}࿏%{&a}", "⟳༒࿏༒⟲", Arrays.asList("⟳༒"), Arrays.asList("༒⟲"));
assertMatch("%{}࿏%{a}", "⟳༒࿏༒⟲", Arrays.asList("a"), Arrays.asList("༒⟲"));
assertMatch(
"Zürich, the %{adjective} city in Switzerland",
"Zürich, the largest city in Switzerland",
Arrays.asList("adjective"),
Arrays.asList("largest")
);
assertMatch(
"Zürich, the %{one} city in Switzerland; Zürich, the %{two} city in Switzerland",
"Zürich, the largest city in Switzerland; Zürich, the best city in Switzerland",
luigidellaquila marked this conversation as resolved.
Show resolved Hide resolved
Arrays.asList("one", "two"),
Arrays.asList("largest", "best")
);
}

public void testMatchRemainder() {
Expand Down