ethsam/symfony-dropzone
Symfony Dropzone Bundle integrates Dropzone.js drag-and-drop uploads into Symfony Forms, with automatic Doctrine entity relationship handling, pre-populated edit forms, image resizing, and configurable single or multiple file modes.
A maintenance release: one dependency that was never declared, the mode nobody had ever run, and three documentation problems found by following the docs literally.
No security change. The 2.1.0 fix is untouched, and nothing here is a regression from it.
symfony/doctrine-bridge is now a declared dependency. The bundle builds a Symfony\Bridge\Doctrine\Form\Type\EntityType whenever multiple is false, and that class ships with the bridge, which appeared in neither require nor require-dev. It worked only because doctrine/doctrine-bundle pulls the bridge in transitively. Installed without it, that one option was a fatal error.
The single-file mode had no test at all, for the same reason: EntityType resolves its choices through a ManagerRegistry, which a mock cannot stand in for. The suite now builds a real in-memory SQLite stack, so the path runs for real and gets the same hostile-filename checks as the multiple mode. It was also exercised in a browser for the first time.
__toString(). The widget renders the entity itself into the hidden field, so the entity example as documented crashed any edit form holding existing files. If your entity is not stringable, add it.symfony-dropzone:sending. That is the case behind the formDataRaw proposal in #2, and the events section never showed it.All three translations updated.
composer update ethsam/symfony-dropzone. No configuration change, no behaviour change. Check that your file entity implements __toString(), and re-read your remove handler against the corrected removal flow above.
Full changelog: https://github.com/ethsam/symfony-dropzone/compare/v2.1.0...v2.1.1
Security release. Upgrading is recommended for every project using 2.0.0 or earlier.
composer require ethsam/symfony-dropzone:^2.1
The widget used to build its inline JavaScript by interpolating application data into it, including the filename of every already attached file:
name: '{{ file.filename }}',
Twig's automatic escaping is HTML escaping, which is the wrong defence inside a <script>: entities are never decoded there, and a filename ending in a backslash cancels the closing quote so the string runs on into the surrounding code. file.size was interpolated outside of any quotes at all.
Filenames come from whoever uploads a file. The minimum consequence is that the script fails to parse, leaving the upload field unusable for anyone opening that record. With control over several filenames the quotes can be realigned, which turns it into stored cross site scripting in the session of whoever opens the form. Every version up to 2.0.0 is affected, as is the original emr-dev/symfony-dropzone this bundle forks.
Everything the browser needs now travels as JSON inside an HTML attribute and is read back with JSON.parse. The inline script is a constant: identical byte for byte whatever the database holds. tests/Form/DropzoneWidgetRenderTest.php renders the widget with hostile stored values and fails if any of them reaches the script.
If you keep a copy of dropzone.html.twig under templates/bundles/SymfonyDropzoneBundle/, that copy overrides the bundle and stays vulnerable after upgrading. Delete it or port your changes.
See SECURITY.md.
maxFilesize option, mapping to Dropzone.js maxFilesize in MiB. Thanks to @nicodemuz for the proposal in #3.symfony-dropzone:init, symfony-dropzone:sending and symfony-dropzone:removedfile DOM events, so applications can extend the widget without overriding the template. This covers the use case behind #2, appending a browser computed value to the upload, without injecting JavaScript from PHP. The prefix avoids a collision with Dropzone.js 6's own dropzone:* events.SECURITY.md with a reporting channel and the rendering rule the bundle follows.setAllowedTypes. A value of the wrong type now raises an exception at form build time instead of being serialised into the page. '5' instead of 5 for maxFiles used to be coerced and now fails.', &, < or > are displayed correctly. They used to show as HTML entities, for instance O'Brien.pdf.<span hidden data-dropzone-config>, next to the form field.No option was renamed or removed, and no application code has to change.
Full changelog: https://github.com/ethsam/symfony-dropzone/compare/v2.0.0...v2.1.0
Complete bundle refactor for production distribution.
Installable via Composer: composer require ethsam/symfony-dropzone:^2.0
#add_property_arrayIdMedia)transform() implementation in DropzoneTransformercomposer.json with all required dependencies and metadatadeclare(strict_types=1) throughoutlibrary to symfony-bundlesetRequired for the class, uploadHandler and removeHandler optionsDropzone.autoDiscover = false to prevent conflicts with other instancesdocs/).gitattributes for clean Composer installs, plus CHANGELOG.md and CONTRIBUTING.mdLICENSEuse App\Entity\File removed from the transformer (broke in non-App namespaces)$options property in the transformer (PHP 8.2 deprecation)true/false instead of 1/0)dropzone.php service config#add_property_arrayIdMedia referencesFull changelog: https://github.com/ethsam/symfony-dropzone/compare/v1.0.0...v2.0.0
Full Changelog: https://github.com/ethsam/symfony-dropzone/commits/v1.0.0
How can I help you explore Laravel packages today?