MCPcopy Create free account
hub / github.com/apache/tomcat / parseParamValues

Method parseParamValues

java/org/apache/catalina/ssi/SSIProcessor.java:272–321  ·  view source on GitHub ↗

Parse a StringBuilder and take out the param token. Called from requestHandler @param cmd a value of type 'StringBuilder' @param start index on which parsing will start @param count number of values which should be parsed @return an array with the parameter values

(StringBuilder cmd, int start, int count)

Source from the content-addressed store, hash-verified

270 * @return an array with the parameter values
271 */
272 protected String[] parseParamValues(StringBuilder cmd, int start, int count) {
273 int valIndex = 0;
274 boolean inside = false;
275 String[] vals = new String[count];
276 StringBuilder sb = new StringBuilder();
277 char endQuote = 0;
278 for (int bIdx = start; bIdx < cmd.length(); bIdx++) {
279 if (!inside) {
280 while (bIdx < cmd.length() && !isQuote(cmd.charAt(bIdx))) {
281 bIdx++;
282 }
283 if (bIdx >= cmd.length()) {
284 break;
285 }
286 inside = true;
287 endQuote = cmd.charAt(bIdx);
288 } else {
289 boolean escaped = false;
290 for (; bIdx < cmd.length(); bIdx++) {
291 char c = cmd.charAt(bIdx);
292 // Check for escapes
293 if (c == '\\' && !escaped) {
294 escaped = true;
295 continue;
296 }
297 // If we reach the other " then stop
298 if (c == endQuote && !escaped) {
299 break;
300 }
301 /*
302 * Since parsing of attributes and var substitution is done in separate places, we need to leave
303 * escape in the string
304 */
305 if (c == '$' && escaped) {
306 sb.append('\\');
307 }
308 escaped = false;
309 sb.append(c);
310 }
311 // If we hit the end without seeing a quote the signal an error
312 if (bIdx == cmd.length()) {
313 return null;
314 }
315 vals[valIndex++] = sb.toString();
316 sb.delete(0, sb.length()); // clear the buffer
317 inside = false;
318 }
319 }
320 return vals;
321 }
322
323
324 /**

Callers 1

processMethod · 0.95

Calls 6

isQuoteMethod · 0.95
lengthMethod · 0.80
charAtMethod · 0.80
toStringMethod · 0.65
deleteMethod · 0.65
appendMethod · 0.45

Tested by

no test coverage detected