Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ VariableNameCharacter

String
: DOUBLEQUOTE StringCharacters? DOUBLEQUOTE
| DOUBLEQUOTE DOUBLEQUOTE DOUBLEQUOTE StringCharacters? DOUBLEQUOTE DOUBLEQUOTE DOUBLEQUOTE
;

fragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ public Object coercePrimaryTerminalNode(final TerminalNode node, final Event eve
case DataPrepperExpressionParser.JsonPointer:
return resolveJsonPointerValue(nodeStringValue, event);
case DataPrepperExpressionParser.String:
final String nodeStringValueWithQuotesStripped = nodeStringValue.substring(1,
nodeStringValue.length() - 1);
return nodeStringValueWithQuotesStripped;
return nodeStringValue.replaceAll("^\"{1,3}|\"{1,3}$", "");
case DataPrepperExpressionParser.Integer:
Long longValue = Long.valueOf(nodeStringValue);
if (longValue > Integer.MAX_VALUE || longValue < Integer.MIN_VALUE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ private static Stream<Arguments> validExpressionArguments() {
arguments("/should_drop", event("{\"should_drop\": true}"), true),
arguments("/should_drop", event("{\"should_drop\": false}"), false),
arguments("/logs/2/should_drop", event("{\"logs\": [{}, {}, {\"should_drop\": true}]}"), true),
arguments("/path == \"\"\"/path/to/route\"\"\"", event("{\"path\": \"/path/to/route\"}"), true),
arguments("/path == \"\"\"/path/to/route\"\"\"", event("{\"path\": \"/incorrect/path\"}"), false),
arguments(
escapedJsonPointer(ALL_JACKSON_EVENT_GET_SUPPORTED_CHARACTERS) + " == true",
complexEvent(ALL_JACKSON_EVENT_GET_SUPPORTED_CHARACTERS, true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,18 @@ void testCoerceTerminalNodeEscapeJsonPointerTypeUnSupportedValues() {
assertThrows(ExpressionCoercionException.class, () -> objectUnderTest.coercePrimaryTerminalNode(terminalNode, testEvent));
}

@ParameterizedTest
@MethodSource("provideSupportedJsonPointerValues")
void testCoerceTerminalNodeTripleQuoteStringTypeSupportedValues(final Object testValue) {
final String testKey = "/testKey";
final String testTruipleQuoteStringKey = "\"\"\"/testKey\"\"\"";
when(token.getType()).thenReturn(DataPrepperExpressionParser.String);
when(terminalNode.getSymbol()).thenReturn(token);
when(terminalNode.getText()).thenReturn(testTruipleQuoteStringKey);
final Object result = objectUnderTest.coercePrimaryTerminalNode(terminalNode, null);
assertThat(result, equalTo(testKey));
}

@Test
void testCoerceTerminalNodeJsonPointerTypeUnSupportedValues() {
final String testKey1 = "key1";
Expand Down
Loading