#111407ext:form: FileUpload field submitted as a plain string crashes with "Cannot unset string offsets"
Description
When a form that contains a FileUpload element is submitted as application/x-www-form-urlencoded (no multipart) and the upload field carries a plain string, the request dies with a PHP Error instead of a validation error:
Error: Cannot unset string offsets in typo3/sysext/form/Classes/Mvc/Property/TypeConverter/UploadedFileReferenceConverter.php:162
Backtrace (shortened):
#0 ContentObjectRenderer->render(UserContentObject)
#1 ContentObjectRenderer->cObjGetSingle('USER')
#2 RequestHandler->processNonCacheableContentPartsAndSubstituteContentMarkers()
...
Caused by Error: Cannot unset string offsets in .../UploadedFileReferenceConverter.php:162
Real browsers never send this, but spam bots do: they post every field of the form as a text value. On a public site this means every bot hit produces a 500 (and an exception log entry) instead of the honeypot / validation error the form would otherwise return. A 500 is also the wrong answer here, because it is the client’s request that is malformed, not the server.
Steps to reproduce
1. Create a form with at least one FileUpload element and place it on a page. 2. Load the page and copy the hidden __state and __trustedProperties values. 3. POST the form urlencoded, with a string in the upload field, e.g. tx_form_formframework[<formId>][fileupload-1]=foo (plus the other fields and the __state / __trustedProperties values).
Result: HTTP 500, “Cannot unset string offsets”.
Expected: the form re-renders with its validation errors; the upload field is treated as “no file uploaded”.
Analysis*
*UploadedFileReferenceConverter::convertFrom() is documented to accept array|UploadedFile|string as $source, and the type converter is registered without a source-type restriction, so a string does reach the method.
In TYPO3 13 the string case was handled implicitly: isset($source[‘error’]) on a string is false, isset($source[‘submittedFile’][‘resourcePointer’]) is false, and the method returned null.
The 14.x multi-upload rewrite only guards ‘’ = $source* / *[] = $source and $source instanceof UploadedFile. A non-empty string falls through to unset($source[‘__deleteFile’]);, which PHP refuses on a string. With allowRemoval enabled it would already fail one line earlier in extractFileDeletionData(array $source) with a TypeError.
*Proposel*
Restore the 13.x behaviour and treat any non-array source as “no file”:
--- a/typo3/sysext/form/Classes/Mvc/Property/TypeConverter/UploadedFileReferenceConverter.php
+++ b/typo3/sysext/form/Classes/Mvc/Property/TypeConverter/UploadedFileReferenceConverter.php
@@ -151,6 +151,10 @@
);
}
+ if (!is_array($source)) {
+ return null;
+ }
+
$allowRemoval = $configuration?->getConfigurationValue(self::class, self::CONFIGURATION_ALLOW_REMOVAL) ?? false;
Verified on a 14.3.11 installation: with the guard the urlencoded bot request returns 200 with the normal validation errors, and a genuine multipart upload is still stored and rendered with its resource pointer as before.
Reviews 1
History 02
-
Gerrit Code Review pushed patch set 1 for main to change 97564 status
NewUnder Review <span data-processor="relativetime" data-value="2026-11-11T20:29:20+00:00" > 11/11/26, 20:29 </span> -
Gerrit Code Review pushed patch set 2 for main to change 97564 <span data-processor="relativetime" data-value="2026-11-19T17:20:40+00:00" > 11/19/26, 17:20 </span>