Skip to content

Commit 2d835e1

Browse files
committed
Simplify to also handle '' quickly
1 parent 59f8f94 commit 2d835e1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/java/com/hubspot/jinjava/util/WhitespaceUtils.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public static boolean isExpressionQuoted(String s) {
6262
return false;
6363
}
6464
char[] charArray = s.trim().toCharArray();
65+
if (charArray.length == 1) {
66+
return false;
67+
}
6568
char quoteChar = 0;
6669
for (char c : QUOTE_CHARS) {
6770
if (charArray[0] == c) {
@@ -79,12 +82,12 @@ public static boolean isExpressionQuoted(String s) {
7982
}
8083
if (prevChar == '\\') {
8184
// Double escapes cancel out.
82-
prevChar = 1;
85+
prevChar = 0;
8386
} else {
8487
prevChar = charArray[i];
8588
}
8689
}
87-
return prevChar != '\\' && prevChar != 0;
90+
return prevChar != '\\';
8891
}
8992

9093
public static String unquote(String s) {

0 commit comments

Comments
 (0)