feat: support Freemarker SpEL packer

This commit is contained in:
ReaJason
2026-08-30 21:05:21 +08:00
parent 3c91ba50e9
commit 0e59054937
14 changed files with 161 additions and 25 deletions
+1
View File
@@ -22,6 +22,7 @@ dependencies {
implementation("ognl:ognl:2.7.3")
implementation("commons-jxpath:commons-jxpath:1.3")
implementation("commons-beanutils:commons-beanutils:1.9.3")
implementation("org.freemarker:freemarker:2.3.23")
}
tasks.test {
@@ -0,0 +1,35 @@
package com.reajason.javaweb.vul.springboot3.controller;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
/**
* @author ReaJason
* @since 2026/8/30
*/
@RestController
@RequestMapping("/freemarker")
public class FreemarkerController {
@PostMapping
public String freemarker(@RequestParam String data) throws IOException, TemplateException {
Configuration configuration = new Configuration();
configuration.setDefaultEncoding("UTF-8");
Map<String, Object> input = new HashMap<>();
input.put("object", new Object());
Template template = new Template("templateName", new StringReader(data), configuration);
StringWriter output = new StringWriter();
template.process(input, output);
return output.toString();
}
}