|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2018 the original author or authors. |
| 2 | + * Copyright 2002-2023 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.
|
@@ -255,16 +255,21 @@ protected MultipartParsingResult parseFileItems(List<FileItem> fileItems, String
|
255 | 255 | for (FileItem fileItem : fileItems) {
|
256 | 256 | if (fileItem.isFormField()) {
|
257 | 257 | String value;
|
258 |
| - String partEncoding = determineEncoding(fileItem.getContentType(), encoding); |
259 |
| - try { |
260 |
| - value = fileItem.getString(partEncoding); |
261 |
| - } |
262 |
| - catch (UnsupportedEncodingException ex) { |
263 |
| - if (logger.isWarnEnabled()) { |
264 |
| - logger.warn("Could not decode multipart item '" + fileItem.getFieldName() + |
265 |
| - "' with encoding '" + partEncoding + "': using platform default"); |
| 258 | + if (fileItem.getSize() > 0) { |
| 259 | + String partEncoding = determineEncoding(fileItem.getContentType(), encoding); |
| 260 | + try { |
| 261 | + value = fileItem.getString(partEncoding); |
| 262 | + } |
| 263 | + catch (UnsupportedEncodingException ex) { |
| 264 | + if (logger.isWarnEnabled()) { |
| 265 | + logger.warn("Could not decode multipart item '" + fileItem.getFieldName() + |
| 266 | + "' with encoding '" + partEncoding + "': using platform default"); |
| 267 | + } |
| 268 | + value = fileItem.getString(); |
266 | 269 | }
|
267 |
| - value = fileItem.getString(); |
| 270 | + } |
| 271 | + else { |
| 272 | + value = ""; |
268 | 273 | }
|
269 | 274 | String[] curParam = multipartParameters.get(fileItem.getFieldName());
|
270 | 275 | if (curParam == null) {
|
|
0 commit comments