From 6fe39dfc65824fc69567ef586129b0afd8f9f97c Mon Sep 17 00:00:00 2001 From: Jack Smith Date: Fri, 20 Oct 2023 11:44:15 -0400 Subject: [PATCH] Add feature stub for preventing accidental expressions --- .../com/hubspot/jinjava/tree/output/OutputList.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/hubspot/jinjava/tree/output/OutputList.java b/src/main/java/com/hubspot/jinjava/tree/output/OutputList.java index 738e9062c..b3f377190 100644 --- a/src/main/java/com/hubspot/jinjava/tree/output/OutputList.java +++ b/src/main/java/com/hubspot/jinjava/tree/output/OutputList.java @@ -1,5 +1,6 @@ package com.hubspot.jinjava.tree.output; +import com.hubspot.jinjava.JinjavaConfig; import com.hubspot.jinjava.interpret.JinjavaInterpreter; import com.hubspot.jinjava.interpret.OutputTooBigException; import com.hubspot.jinjava.interpret.TemplateError; @@ -8,6 +9,8 @@ import java.util.List; public class OutputList { + public static final String PREVENT_ACCIDENTAL_EXPRESSIONS = + "PREVENT_ACCIDENTAL_EXPRESSIONS"; private final List nodes = new LinkedList<>(); private final List blocks = new LinkedList<>(); private final long maxOutputSize; @@ -46,6 +49,16 @@ public List getBlocks() { } public String getValue() { + boolean preventAccidentalExpressions = JinjavaInterpreter + .getCurrentMaybe() + .map(JinjavaInterpreter::getConfig) + .map(JinjavaConfig::getFeatures) + .map( + features -> + features.getActivationStrategy(PREVENT_ACCIDENTAL_EXPRESSIONS).isActive(null) + ) + .orElse(false); + LengthLimitingStringBuilder val = new LengthLimitingStringBuilder(maxOutputSize); for (OutputNode node : nodes) {