File tree Expand file tree Collapse file tree
main/java/com/hubspot/jinjava/tree/parse
java/com/hubspot/jinjava/tree/parse
resources/parse/tokenizer Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,17 +68,15 @@ private Token getNextToken() {
6868 }
6969
7070 if (inBlock > 0 ) {
71- if (inQuote != 0 ) {
71+ if (c == '\\' ) {
72+ ++currPost ;
73+ continue ;
74+ } else if (inQuote != 0 ) {
7275 if (inQuote == c ) {
7376 inQuote = 0 ;
74- continue ;
75- } else if (c == '\\' ) {
76- ++currPost ;
77- continue ;
78- } else {
79- continue ;
8077 }
81- } else if (inQuote == 0 && (c == '\'' || c == '"' )) {
78+ continue ;
79+ } else if (c == '\'' || c == '"' ) {
8280 inQuote = c ;
8381 continue ;
8482 }
Original file line number Diff line number Diff line change @@ -305,6 +305,23 @@ public void testLstripBlocks() {
305305 assertThat (tokens ).isNotEmpty ();
306306 }
307307
308+ @ Test
309+ public void itTreatsEscapedQuotesSameWhenNotInQuotes () {
310+ List <Token > tokens = tokens ("tag-with-all-escaped-quotes" );
311+ assertThat (tokens ).hasSize (8 );
312+ assertThat (tokens .stream ().map (Token ::getType ).collect (Collectors .toList ()))
313+ .containsExactly (
314+ symbols .getNote (),
315+ symbols .getFixed (),
316+ symbols .getTag (),
317+ symbols .getFixed (),
318+ symbols .getTag (),
319+ symbols .getFixed (),
320+ symbols .getTag (),
321+ symbols .getFixed ()
322+ );
323+ }
324+
308325 private List <Token > tokens (String fixture ) {
309326 TokenScanner t = fixture (fixture );
310327 return Lists .newArrayList (t );
Original file line number Diff line number Diff line change 1+ {# This print tag is invalid, but it should not cause the rest of the template to break #}
2+ {% print \"foo\" %}
3+ Start
4+ {% if true %}
5+ The dog says: "Woof!"
6+ {% endif %}
7+ End
You can’t perform that action at this time.
0 commit comments