@@ -27,13 +27,20 @@ public boolean string3(javax.servlet.http.HttpServletRequest request) {
27
27
String pattern = request .getParameter ("pattern" );
28
28
String input = request .getParameter ("input" );
29
29
30
- return input .replaceFirst (pattern , "" ).length () > 0 ; // $ hasRegexInjection
30
+ return input .split (pattern , 0 ).length > 0 ; // $ hasRegexInjection
31
31
}
32
32
33
33
public boolean string4 (javax .servlet .http .HttpServletRequest request ) {
34
34
String pattern = request .getParameter ("pattern" );
35
35
String input = request .getParameter ("input" );
36
36
37
+ return input .replaceFirst (pattern , "" ).length () > 0 ; // $ hasRegexInjection
38
+ }
39
+
40
+ public boolean string5 (javax .servlet .http .HttpServletRequest request ) {
41
+ String pattern = request .getParameter ("pattern" );
42
+ String input = request .getParameter ("input" );
43
+
37
44
return input .replaceAll (pattern , "" ).length () > 0 ; // $ hasRegexInjection
38
45
}
39
46
@@ -58,13 +65,20 @@ public boolean pattern3(javax.servlet.http.HttpServletRequest request) {
58
65
String pattern = request .getParameter ("pattern" );
59
66
String input = request .getParameter ("input" );
60
67
61
- return Pattern .matches (pattern , input ); // $ hasRegexInjection
68
+ return Pattern .compile (pattern , 0 ). matcher ( input ). matches ( ); // $ hasRegexInjection
62
69
}
63
70
64
71
public boolean pattern4 (javax .servlet .http .HttpServletRequest request ) {
65
72
String pattern = request .getParameter ("pattern" );
66
73
String input = request .getParameter ("input" );
67
74
75
+ return Pattern .matches (pattern , input ); // $ hasRegexInjection
76
+ }
77
+
78
+ public boolean pattern5 (javax .servlet .http .HttpServletRequest request ) {
79
+ String pattern = request .getParameter ("pattern" );
80
+ String input = request .getParameter ("input" );
81
+
68
82
return input .matches ("^" + foo (pattern ) + "=.*$" ); // $ hasRegexInjection
69
83
}
70
84
0 commit comments