|
8 | 8 | import com.google.common.collect.Lists; |
9 | 9 | import com.hubspot.jinjava.Jinjava; |
10 | 10 | import com.hubspot.jinjava.JinjavaConfig; |
11 | | -import com.hubspot.jinjava.features.FeatureConfig; |
12 | | -import com.hubspot.jinjava.features.FeatureStrategies; |
13 | 11 | import com.hubspot.jinjava.interpret.JinjavaInterpreter.InterpreterScopeClosable; |
14 | 12 | import com.hubspot.jinjava.interpret.TemplateError.ErrorItem; |
15 | 13 | import com.hubspot.jinjava.interpret.TemplateError.ErrorReason; |
16 | 14 | import com.hubspot.jinjava.interpret.TemplateError.ErrorType; |
17 | | -import com.hubspot.jinjava.mode.EagerExecutionMode; |
18 | 15 | import com.hubspot.jinjava.mode.PreserveRawExecutionMode; |
19 | 16 | import com.hubspot.jinjava.objects.date.FormattedDate; |
20 | 17 | import com.hubspot.jinjava.objects.date.StrftimeFormatter; |
21 | 18 | import com.hubspot.jinjava.tree.TextNode; |
22 | 19 | import com.hubspot.jinjava.tree.output.BlockInfo; |
23 | | -import com.hubspot.jinjava.tree.output.OutputList; |
24 | 20 | import com.hubspot.jinjava.tree.parse.TextToken; |
25 | 21 | import com.hubspot.jinjava.tree.parse.TokenScannerSymbols; |
26 | 22 | import java.time.ZoneId; |
@@ -507,53 +503,4 @@ public void itFiltersDuplicateErrors() { |
507 | 503 |
|
508 | 504 | assertThat(interpreter.getErrors()).containsExactly(error1, error2); |
509 | 505 | } |
510 | | - |
511 | | - @Test |
512 | | - public void itPreventsAccidentalExpressions() { |
513 | | - String makeExpression = "if (true) {\n{%- print deferred -%}\n}"; |
514 | | - String makeTag = "if (true) {\n{%- print '% print 123 %' -%}\n}"; |
515 | | - String makeNote = "if (true) {\n{%- print '# note #' -%}\n}"; |
516 | | - jinjava.getGlobalContext().put("deferred", DeferredValue.instance()); |
517 | | - |
518 | | - JinjavaInterpreter normalInterpreter = new JinjavaInterpreter( |
519 | | - jinjava, |
520 | | - jinjava.getGlobalContext(), |
521 | | - JinjavaConfig.newBuilder().withExecutionMode(EagerExecutionMode.instance()).build() |
522 | | - ); |
523 | | - JinjavaInterpreter preventingInterpreter = new JinjavaInterpreter( |
524 | | - jinjava, |
525 | | - jinjava.getGlobalContext(), |
526 | | - JinjavaConfig |
527 | | - .newBuilder() |
528 | | - .withFeatureConfig( |
529 | | - FeatureConfig |
530 | | - .newBuilder() |
531 | | - .add(OutputList.PREVENT_ACCIDENTAL_EXPRESSIONS, FeatureStrategies.ACTIVE) |
532 | | - .build() |
533 | | - ) |
534 | | - .withExecutionMode(EagerExecutionMode.instance()) |
535 | | - .build() |
536 | | - ); |
537 | | - JinjavaInterpreter.pushCurrent(normalInterpreter); |
538 | | - try { |
539 | | - assertThat(normalInterpreter.render(makeExpression)) |
540 | | - .isEqualTo("if (true) {{% print deferred %}}"); |
541 | | - assertThat(normalInterpreter.render(makeTag)) |
542 | | - .isEqualTo("if (true) {% print 123 %}"); |
543 | | - assertThat(normalInterpreter.render(makeNote)).isEqualTo("if (true) {# note #}"); |
544 | | - } finally { |
545 | | - JinjavaInterpreter.popCurrent(); |
546 | | - } |
547 | | - JinjavaInterpreter.pushCurrent(preventingInterpreter); |
548 | | - try { |
549 | | - assertThat(preventingInterpreter.render(makeExpression)) |
550 | | - .isEqualTo("if (true) {\n" + "{#- #}{% print deferred %}}"); |
551 | | - assertThat(preventingInterpreter.render(makeTag)) |
552 | | - .isEqualTo("if (true) {\n" + "{#- #}% print 123 %}"); |
553 | | - assertThat(preventingInterpreter.render(makeNote)) |
554 | | - .isEqualTo("if (true) {\n" + "{#- #}# note #}"); |
555 | | - } finally { |
556 | | - JinjavaInterpreter.popCurrent(); |
557 | | - } |
558 | | - } |
559 | 506 | } |
0 commit comments