File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
main/java/com/hubspot/jinjava/util
test/java/com/hubspot/jinjava/util Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,10 @@ public static boolean isExpressionQuoted(String s) {
6161 if (Strings .isNullOrEmpty (s )) {
6262 return false ;
6363 }
64- char [] charArray = s .toCharArray ();
64+ 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 ) {
Original file line number Diff line number Diff line change @@ -49,4 +49,17 @@ public void itKnowsWhenAnExpressionIsQuoted() {
4949 assertThat (isExpressionQuoted ("\" foo 'and' bar\" " )).isTrue ();
5050 assertThat (isExpressionQuoted ("\" foo 'and' bar'" )).isFalse ();
5151 }
52+
53+ @ Test
54+ public void itKnowsUntrimmedExpressionIsQuoted () {
55+ assertThat (isExpressionQuoted (" 'foo'" )).isTrue ();
56+ assertThat (isExpressionQuoted ("'foo' " )).isTrue ();
57+ assertThat (isExpressionQuoted (" 'foo' " )).isTrue ();
58+ }
59+
60+ @ Test
61+ public void itDoesntCountSingleQuoteChar () {
62+ assertThat (isExpressionQuoted ("'" )).isFalse ();
63+ assertThat (isExpressionQuoted ("\" " )).isFalse ();
64+ }
5265}
You can’t perform that action at this time.
0 commit comments