Skip to content

Commit

Permalink
Merge pull request quarkusio#25358 from mkouba/qute-str-literal-support
Browse files Browse the repository at this point in the history
Qute - fix string LiteralSupport
  • Loading branch information
mkouba authored May 4, 2022
2 parents f0763cc + ce9c6fa commit 43070cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ static Object getLiteralValue(String literal) {
if (literal == null || literal.isEmpty()) {
return value;
}
if (isStringLiteralSeparator(literal.charAt(0))) {
char firstChar = literal.charAt(0);
if (isStringLiteralSeparator(firstChar) && literal.charAt(literal.length() - 1) == firstChar) {
value = literal.substring(1, literal.length() - 1);
} else if (literal.equals("true")) {
value = Boolean.TRUE;
Expand All @@ -31,7 +32,6 @@ static Object getLiteralValue(String literal) {
} else if (literal.equals("null")) {
value = null;
} else {
char firstChar = literal.charAt(0);
if (Character.isDigit(firstChar) || firstChar == '-' || firstChar == '+') {
if (INTEGER_LITERAL_PATTERN.matcher(literal).matches()) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,10 @@ public void testLiteralsInTemplate() {
assertEquals("OK", engine.parse("{#if 'foo' == false}NOK{#else}OK{/if}").render());
}

@Test
public void testNonLiteral() {
assertEquals(Results.NotFound.EMPTY, LiteralSupport.getLiteralValue("'foo'.ping()"));
assertEquals(Results.NotFound.EMPTY, LiteralSupport.getLiteralValue("foo.bar"));
}

}

0 comments on commit 43070cb

Please sign in to comment.