pebble icon indicating copy to clipboard operation
pebble copied to clipboard

Backslash parsing fails in replace function in template

Open zhangyongxianggithub opened this issue 1 year ago • 3 comments

version:

            <dependency>
                <groupId>io.pebbletemplates</groupId>
                <artifactId>pebble-spring-boot-starter</artifactId>
                <version>3.2.1</version>
            </dependency>

template snippet: COMMENT='{{- comment | replace({'\':'\\'}) | replace({"'":"\'"}) | raw -}}' exception information:

Exception in thread "main" io.pebbletemplates.pebble.error.ParserException: Unexpected character [] (rules/ddl:7) at io.pebbletemplates.pebble.lexer.LexerImpl.tokenizeExpression(LexerImpl.java:509) at io.pebbletemplates.pebble.lexer.LexerImpl.tokenizeBetweenPrintDelimiters(LexerImpl.java:369) at io.pebbletemplates.pebble.lexer.LexerImpl.tokenize(LexerImpl.java:192) at io.pebbletemplates.pebble.PebbleEngine.getPebbleTemplate(PebbleEngine.java:164) at io.pebbletemplates.pebble.PebbleEngine.lambda$getTemplate$0(PebbleEngine.java:152) at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708) at io.pebbletemplates.pebble.cache.template.ConcurrentMapTemplateCache.computeIfAbsent(ConcurrentMapTemplateCache.java:25) at io.pebbletemplates.pebble.cache.template.ConcurrentMapTemplateCache.computeIfAbsent(ConcurrentMapTemplateCache.java:10) at io.pebbletemplates.pebble.PebbleEngine.getTemplate(PebbleEngine.java:152) at io.pebbletemplates.pebble.PebbleEngine.getTemplate(PebbleEngine.java:123)

zhangyongxianggithub avatar Feb 01 '24 09:02 zhangyongxianggithub

Please submit a valid test case demonstrating your issue

ebussieres avatar Mar 04 '24 14:03 ebussieres

Please submit a valid test case demonstrating your issue

I have checked the source code,a single \ character really cannot be replaced, but if with other character, it can be replaced

zhangyongxianggithub avatar Mar 24 '24 13:03 zhangyongxianggithub