@@ -23,8 +23,7 @@ public void bad1(HttpServletRequest request) {
23
23
String code = request .getParameter ("code" );
24
24
Reader reader = new StringReader (code );
25
25
26
- // Template(java.lang.String name, java.io.Reader reader)
27
- Template t = new Template (name , reader );
26
+ Template t = new Template (name , reader ); // $hasTemplateInjection
28
27
}
29
28
30
29
@ GetMapping (value = "bad2" )
@@ -33,9 +32,8 @@ public void bad2(HttpServletRequest request) {
33
32
String code = request .getParameter ("code" );
34
33
Reader reader = new StringReader (code );
35
34
Configuration cfg = new Configuration ();
36
-
37
- // Template(java.lang.String name, java.io.Reader reader, Configuration cfg)
38
- Template t = new Template (name , reader , cfg );
35
+
36
+ Template t = new Template (name , reader , cfg ); // $hasTemplateInjection
39
37
}
40
38
41
39
@ GetMapping (value = "bad3" )
@@ -45,9 +43,7 @@ public void bad3(HttpServletRequest request) {
45
43
Reader reader = new StringReader (code );
46
44
Configuration cfg = new Configuration ();
47
45
48
- // Template(java.lang.String name, java.io.Reader reader, Configuration cfg,
49
- // java.lang.String encoding)
50
- Template t = new Template (name , reader , cfg , "UTF-8" );
46
+ Template t = new Template (name , reader , cfg , "UTF-8" ); // $hasTemplateInjection
51
47
}
52
48
53
49
@ GetMapping (value = "bad4" )
@@ -56,9 +52,7 @@ public void bad4(HttpServletRequest request) {
56
52
String sourceCode = request .getParameter ("sourceCode" );
57
53
Configuration cfg = new Configuration ();
58
54
59
- // Template(java.lang.String name, java.lang.String sourceCode, Configuration
60
- // cfg)
61
- Template t = new Template (name , sourceCode , cfg );
55
+ Template t = new Template (name , sourceCode , cfg ); // $hasTemplateInjection
62
56
}
63
57
64
58
@ GetMapping (value = "bad5" )
@@ -68,9 +62,7 @@ public void bad5(HttpServletRequest request) {
68
62
Configuration cfg = new Configuration ();
69
63
Reader reader = new StringReader (code );
70
64
71
- // Template(java.lang.String name, java.lang.String sourceName, java.io.Reader
72
- // reader, Configuration cfg)
73
- Template t = new Template (name , sourceName , reader , cfg );
65
+ Template t = new Template (name , sourceName , reader , cfg ); // $hasTemplateInjection
74
66
}
75
67
76
68
@ GetMapping (value = "bad6" )
@@ -81,10 +73,8 @@ public void bad6(HttpServletRequest request) {
81
73
ParserConfiguration customParserConfiguration = new Configuration ();
82
74
Reader reader = new StringReader (code );
83
75
84
- // Template(java.lang.String name, java.lang.String sourceName, java.io.Reader
85
- // reader, Configuration cfg, ParserConfiguration customParserConfiguration,
86
- // java.lang.String encoding)
87
- Template t = new Template (name , sourceName , reader , cfg , customParserConfiguration , "UTF-8" );
76
+ Template t =
77
+ new Template (name , sourceName , reader , cfg , customParserConfiguration , "UTF-8" ); // $hasTemplateInjection
88
78
}
89
79
90
80
@ GetMapping (value = "bad7" )
@@ -95,38 +85,33 @@ public void bad7(HttpServletRequest request) {
95
85
ParserConfiguration customParserConfiguration = new Configuration ();
96
86
Reader reader = new StringReader (code );
97
87
98
- // Template(java.lang.String name, java.lang.String sourceName, java.io.Reader
99
- // reader, Configuration cfg, java.lang.String encoding)
100
- Template t = new Template (name , sourceName , reader , cfg , "UTF-8" );
88
+ Template t = new Template (name , sourceName , reader , cfg , "UTF-8" ); // $hasTemplateInjection
101
89
}
102
90
103
91
@ GetMapping (value = "bad8" )
104
92
public void bad8 (HttpServletRequest request ) {
105
93
String code = request .getParameter ("code" );
106
94
StringTemplateLoader stringLoader = new StringTemplateLoader ();
107
95
108
- // void putTemplate(java.lang.String name, java.lang.String templateContent)
109
- stringLoader .putTemplate ("myTemplate" , code );
96
+ stringLoader .putTemplate ("myTemplate" , code ); // $hasTemplateInjection
110
97
}
111
98
112
99
@ GetMapping (value = "bad9" )
113
100
public void bad9 (HttpServletRequest request ) {
114
101
String code = request .getParameter ("code" );
115
102
StringTemplateLoader stringLoader = new StringTemplateLoader ();
116
-
117
- // void putTemplate(java.lang.String name, java.lang.String templateContent,
118
- // long lastModified)
119
- stringLoader .putTemplate ("myTemplate" , code , 0 );
103
+
104
+ stringLoader .putTemplate ("myTemplate" , code , 0 ); // $hasTemplateInjection
120
105
}
121
106
122
107
@ GetMapping (value = "bad10" )
123
108
public void bad10 (HttpServletRequest request ) {
124
- HashMap <Object ,Object > root = new HashMap ();
109
+ HashMap <Object , Object > root = new HashMap ();
125
110
String code = request .getParameter ("code" );
126
- root .put ("code" , code );
111
+ root .put ("code" , code );
127
112
Configuration cfg = new Configuration ();
128
- Template temp = cfg .getTemplate ("test.ftlh" );
129
- OutputStreamWriter out = new OutputStreamWriter (System .out );
130
- temp .process (root , out );
113
+ Template temp = cfg .getTemplate ("test.ftlh" );
114
+ OutputStreamWriter out = new OutputStreamWriter (System .out );
115
+ temp .process (root , out ); // $hasTemplateInjection
131
116
}
132
117
}
0 commit comments