Skip to content

Commit

Permalink
Allow . and @ characters to be part of json pointer in expressions (o…
Browse files Browse the repository at this point in the history
…pensearch-project#4130)

Signed-off-by: Krishna Kondaka <[email protected]>
Co-authored-by: Krishna Kondaka <[email protected]>
  • Loading branch information
kkondaka and Krishna Kondaka authored Feb 15, 2024
1 parent 117ab26 commit 9d1ae74
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ JsonPointerCharacters

fragment
JsonPointerCharacter
: [A-Za-z0-9_]
: [A-Za-z0-9_.@]
;

EscapedJsonPointer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ private static Stream<Arguments> validExpressionArguments() {
Arguments.of("/status_code == 200", event("{}"), false),
Arguments.of("/success == /status_code", event("{\"success\": true, \"status_code\": 200}"), false),
Arguments.of("/success != /status_code", event("{\"success\": true, \"status_code\": 200}"), true),
Arguments.of("/[email protected] != 111", event("{\"success\": true, \"[email protected]\":111, \"status_code\": 200}"), false),
Arguments.of("/part1.part2@part3 != 111", event("{\"success\": true, \"part1.part2@part3\":222, \"status_code\": 200}"), true),
Arguments.of("/pi == 3.14159", event("{\"pi\": 3.14159}"), true),
Arguments.of("/value == 12345.678", event("{\"value\": 12345.678}"), true),
Arguments.of("/value == 12345.678E12", event("{\"value\": 12345.678E12}"), true),
Expand Down
2 changes: 1 addition & 1 deletion docs/expression_syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Hard coded token that identifies the operation use in an _Expression_.

### Json Pointer
A Literal used to reference a value within the Event provided as context for the _Expression String_. Json Pointers are identified by a
leading `/` containing alphanumeric character or underscores, delimited by `/`. Json Pointers can use an extended character set if wrapped
leading `/` containing one of more of characters from the set `a-zA-Z0-9_.@` , delimited by `/`. Json Pointers can use an extended character set if wrapped
in double quotes (`"`) using the escape character `\`. Note, Json Pointer require `~` and `/` that should be used as part of the path and
not a delimiter to be escaped.

Expand Down

0 comments on commit 9d1ae74

Please sign in to comment.