X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Ffile%2Fsrc%2FElement%2FManagedFile.php;h=95798c6734de0c3f48efe759d61cc382392a3212;hb=5b8bb166bfa98770daef9de5c127fc2e6ef02340;hp=ca4e887a1b3fd193006cd2eb657a8fceacf18f8f;hpb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;p=yaffs-website diff --git a/web/core/modules/file/src/Element/ManagedFile.php b/web/core/modules/file/src/Element/ManagedFile.php index ca4e887a1..95798c673 100644 --- a/web/core/modules/file/src/Element/ManagedFile.php +++ b/web/core/modules/file/src/Element/ManagedFile.php @@ -8,6 +8,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\ReplaceCommand; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Render\Element; use Drupal\Core\Render\Element\FormElement; use Drupal\Core\Site\Settings; use Drupal\Core\Url; @@ -175,6 +176,9 @@ class ManagedFile extends FormElement { $form_parents = explode('/', $request->query->get('element_parents')); + // Sanitize form parents before using them. + $form_parents = array_filter($form_parents, [Element::class, 'child']); + // Retrieve the element to be rendered. $form = NestedArray::getValue($form, $form_parents); @@ -295,6 +299,10 @@ class ManagedFile extends FormElement { // Add the upload progress callback. $element['upload_button']['#ajax']['progress']['url'] = Url::fromRoute('file.ajax_progress', ['key' => $upload_progress_key]); + + // Set a custom submit event so we can modify the upload progress + // identifier element before the form gets submitted. + $element['upload_button']['#ajax']['event'] = 'fileUpload'; } // The file upload field itself.