You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Returns validated input as a String with optional canonicalization. Invalid input will generate a descriptive ValidationException,
90
+
* and input that is clearly an attack will generate a descriptive IntrusionException.
91
+
*
92
+
* @param context
93
+
* A descriptive name of the parameter that you are validating (e.g., LoginPage_UsernameField). This value is used by any logging or error handling that is done with respect to the value passed in.
94
+
* @param input
95
+
* The actual user input data to validate.
96
+
* @param type
97
+
* The regular expression name that maps to the actual regular expression from "ESAPI.properties".
98
+
* @param maxLength
99
+
* The maximum post-canonicalized String length allowed.
100
+
* @param allowNull
101
+
* If allowNull is true then an input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.
102
+
* @param canonicalize
103
+
* If canonicalize is true then input will be canonicalized before validation
* Validates data received from the browser and returns a safe version. Only
179
+
* URL encoding is supported. Double encoding is treated as an attack.
180
+
*
181
+
* @param context A descriptive name for the field to validate. This is used for error facing validation messages and element identification.
182
+
* @param input The actual user input data to validate.
183
+
* @param type The regular expression name which maps to the actual regular expression from "ESAPI.properties".
184
+
* @param maxLength The maximum String length allowed. If input is canonicalized per the canonicalize argument, then maxLength must be verified after canonicalization
185
+
* @param allowNull If allowNull is true then a input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.
186
+
* @param canonicalize If canonicalize is true then input will be canonicalized before validation
187
+
* @return The user input, may be canonicalized if canonicalize argument is true
Patternp = ESAPI.securityConfiguration().getValidationPattern( type );
166
194
if ( p != null ) {
@@ -170,25 +198,45 @@ public String getValidInput(String context, String input, String type, int maxLe
170
198
}
171
199
rvr.setMaximumLength(maxLength);
172
200
rvr.setAllowNull(allowNull);
201
+
rvr.setValidateInputAndCanonical(canonicalize);
173
202
returnrvr.getValid(context, input);
174
203
}
175
204
176
205
/**
177
206
* Validates data received from the browser and returns a safe version. Only
178
-
* URL encoding is supported. Double encoding is treated as an attack.
207
+
* URL encoding is supported. Double encoding is treated as an attack. Input
208
+
* is canonicalized by default before validation.
179
209
*
180
210
* @param context A descriptive name for the field to validate. This is used for error facing validation messages and element identification.
181
211
* @param input The actual user input data to validate.
182
212
* @param type The regular expression name while maps to the actual regular expression from "ESAPI.properties".
183
-
* @param maxLength The maximum post-canonicalized String length allowed.
213
+
* @param maxLength The maximum String length allowed. If input is canonicalized per the canonicalize argument, then maxLength must be verified after canonicalization
184
214
* @param allowNull If allowNull is true then a input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.
185
215
* @param errors If ValidationException is thrown, then add to error list instead of throwing out to caller
* Validates data received from the browser and returns a safe version. Only
225
+
* URL encoding is supported. Double encoding is treated as an attack.
226
+
*
227
+
* @param context A descriptive name for the field to validate. This is used for error facing validation messages and element identification.
228
+
* @param input The actual user input data to validate.
229
+
* @param type The regular expression name while maps to the actual regular expression from "ESAPI.properties".
230
+
* @param maxLength The maximum post-canonicalized String length allowed
231
+
* @param allowNull If allowNull is true then a input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.
232
+
* @param canonicalize If canonicalize is true then input will be canonicalized before validation
233
+
* @param errors If ValidationException is thrown, then add to error list instead of throwing out to caller
234
+
* @return The user input, may be canonicalized if canonicalize argument is true
0 commit comments