|
1 | 1 | /* |
2 | | - * Copyright 2002-2024 the original author or authors. |
| 2 | + * Copyright 2002-2025 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -350,27 +350,22 @@ public MultiValueMap<String, String> read(@Nullable Class<? extends MultiValueMa |
350 | 350 |
|
351 | 351 | String[] pairs = StringUtils.tokenizeToStringArray(body, "&"); |
352 | 352 | MultiValueMap<String, String> result = new LinkedMultiValueMap<>(pairs.length); |
353 | | - for (String pair : pairs) { |
354 | | - int idx = pair.indexOf('='); |
355 | | - if (idx == -1) { |
356 | | - try { |
| 353 | + try { |
| 354 | + for (String pair : pairs) { |
| 355 | + int idx = pair.indexOf('='); |
| 356 | + if (idx == -1) { |
357 | 357 | result.add(URLDecoder.decode(pair, charset), null); |
358 | 358 | } |
359 | | - catch (IllegalArgumentException ex) { |
360 | | - throw new HttpMessageNotReadableException("Could not decode HTTP form payload", ex, inputMessage); |
361 | | - } |
362 | | - } |
363 | | - else { |
364 | | - try { |
| 359 | + else { |
365 | 360 | String name = URLDecoder.decode(pair.substring(0, idx), charset); |
366 | 361 | String value = URLDecoder.decode(pair.substring(idx + 1), charset); |
367 | 362 | result.add(name, value); |
368 | 363 | } |
369 | | - catch (IllegalArgumentException ex) { |
370 | | - throw new HttpMessageNotReadableException("Could not decode HTTP form payload", ex, inputMessage); |
371 | | - } |
372 | 364 | } |
373 | 365 | } |
| 366 | + catch (IllegalArgumentException ex) { |
| 367 | + throw new HttpMessageNotReadableException("Could not decode HTTP form payload", ex, inputMessage); |
| 368 | + } |
374 | 369 | return result; |
375 | 370 | } |
376 | 371 |
|
|
0 commit comments