From 46859d63919f72d192b8c6ca65432c5f3d966a1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Mon, 17 Mar 2025 11:39:15 +0100 Subject: [PATCH] Polishing Closes gh-34594 --- .../converter/FormHttpMessageConverter.java | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java index 7e72fad230..38295f2895 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -350,27 +350,22 @@ public class FormHttpMessageConverter implements HttpMessageConverter result = new LinkedMultiValueMap<>(pairs.length); - for (String pair : pairs) { - int idx = pair.indexOf('='); - if (idx == -1) { - try { + try { + for (String pair : pairs) { + int idx = pair.indexOf('='); + if (idx == -1) { result.add(URLDecoder.decode(pair, charset), null); } - catch (IllegalArgumentException ex) { - throw new HttpMessageNotReadableException("Could not decode HTTP form payload", ex, inputMessage); - } - } - else { - try { + else { String name = URLDecoder.decode(pair.substring(0, idx), charset); String value = URLDecoder.decode(pair.substring(idx + 1), charset); result.add(name, value); } - catch (IllegalArgumentException ex) { - throw new HttpMessageNotReadableException("Could not decode HTTP form payload", ex, inputMessage); - } } } + catch (IllegalArgumentException ex) { + throw new HttpMessageNotReadableException("Could not decode HTTP form payload", ex, inputMessage); + } return result; }