From d53b41995f4c6a2eec909bb6ac9cb772f898264c Mon Sep 17 00:00:00 2001 From: Andreas Fernandez <a.fernandez@scripting-base.de> Date: Thu, 30 Mar 2023 10:41:46 +0200 Subject: [PATCH] [BUGFIX] Do not send table wizard fields in payload The fields used in the table wizard are only used for internal handling to be able to compose the final table markup sent to DataHandler. The "management fields" are not interesting on server side and therefore their respective `name` attributes are removed to avoid sending potentially huge, superfluous data. Resolves: #100354 Releases: main, 12.4 Change-Id: If833f2bd1208a050dc88bc1844a19d9fbb209614 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/78973 Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de> Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de> Tested-by: core-ci <typo3@b13.com> --- .../backend/element/table-wizard-element.ts | 6 ++-- .../element/table-wizard-element.js | 6 ++-- .../ElementsBasicInputTextTableCest.php | 30 +++++++++---------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Build/Sources/TypeScript/backend/element/table-wizard-element.ts b/Build/Sources/TypeScript/backend/element/table-wizard-element.ts index 00a6e3c5e8bb..2d67f6817f1c 100644 --- a/Build/Sources/TypeScript/backend/element/table-wizard-element.ts +++ b/Build/Sources/TypeScript/backend/element/table-wizard-element.ts @@ -186,7 +186,7 @@ export class TableWizardElement extends LitElement { <tbody> ${this.table.map((row: string[], rowIndex: number) => html` <tr> - <th>${this.renderRowButtons(rowIndex, lastRowIndex)}</th> + <td>${this.renderRowButtons(rowIndex, lastRowIndex)}</td> ${row.map((value: string, colIndex: number) => html` <td>${this.renderDataElement(value, rowIndex, colIndex)}</td> `)} @@ -203,13 +203,13 @@ export class TableWizardElement extends LitElement { switch (this.type) { case 'input': return html` - <input class="form-control" type="text" name="TABLE[c][${rowIndex}][${colIndex}]" + <input class="form-control" type="text" data-row="${rowIndex}" data-col="${colIndex}" @change="${modifyTable}" .value="${value.replace(/\n/g, '<br>')}"> `; case 'textarea': default: return html` - <textarea class="form-control" rows="6" name="TABLE[c][${rowIndex}][${colIndex}]" + <textarea class="form-control" rows="6" data-row="${rowIndex}" data-col="${colIndex}" @change="${modifyTable}" .value="${value.replace(/<br[ ]*\/?>/g, '\n')}"></textarea> `; } diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/element/table-wizard-element.js b/typo3/sysext/backend/Resources/Public/JavaScript/element/table-wizard-element.js index 9b556ceb8f6b..a3c6cc0ea761 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/element/table-wizard-element.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/element/table-wizard-element.js @@ -25,7 +25,7 @@ var __decorate=function(t,e,l,a){var o,n=arguments.length,i=n<3?e:null===a?a=Obj <tbody> ${this.table.map(((t,e)=>html` <tr> - <th>${this.renderRowButtons(e,l)}</th> + <td>${this.renderRowButtons(e,l)}</td> ${t.map(((t,l)=>html` <td>${this.renderDataElement(t,e,l)}</td> `))} @@ -35,10 +35,10 @@ var __decorate=function(t,e,l,a){var o,n=arguments.length,i=n<3?e:null===a?a=Obj </table> </div> `}renderDataElement(t,e,l){const a=t=>this.modifyTable(t,e,l);return"input"===this.type?html` - <input class="form-control" type="text" name="TABLE[c][${e}][${l}]" + <input class="form-control" type="text" data-row="${e}" data-col="${l}" @change="${a}" .value="${t.replace(/\n/g,"<br>")}"> `:html` - <textarea class="form-control" rows="6" name="TABLE[c][${e}][${l}]" + <textarea class="form-control" rows="6" data-row="${e}" data-col="${l}" @change="${a}" .value="${t.replace(/<br[ ]*\/?>/g,"\n")}"></textarea> `}renderTypeButton(){return html` <span class="btn-group"> diff --git a/typo3/sysext/core/Tests/Acceptance/Application/FormEngine/ElementsBasicInputTextTableCest.php b/typo3/sysext/core/Tests/Acceptance/Application/FormEngine/ElementsBasicInputTextTableCest.php index 6194bdc66cfe..d4b1c401cc3b 100644 --- a/typo3/sysext/core/Tests/Acceptance/Application/FormEngine/ElementsBasicInputTextTableCest.php +++ b/typo3/sysext/core/Tests/Acceptance/Application/FormEngine/ElementsBasicInputTextTableCest.php @@ -70,7 +70,7 @@ final class ElementsBasicInputTextTableCest extends AbstractElementsBasicCest $I->amGoingTo('check for correct data in each column'); foreach ($this->tableDataProvider() as $keyRow => $row) { foreach ($row as $keyCol => $col) { - $input = $this->getTable($I)->findElement(WebDriverBy::cssSelector('input[name="TABLE[c][' . $keyRow . '][' . $keyCol . ']"]')); + $input = $this->getTable($I)->findElement(WebDriverBy::cssSelector('input[data-row="' . $keyRow . '"][data-col="' . $keyCol . '"]')); $value = $input->getAttribute('value'); $I->assertEquals($col, $value); } @@ -92,12 +92,12 @@ final class ElementsBasicInputTextTableCest extends AbstractElementsBasicCest ], [ 'description' => 'add a row', - 'click' => 'typo3-backend-table-wizard tbody tr:first-child > th button[title="Add row below"]', + 'click' => 'typo3-backend-table-wizard tbody tr:first-child > td button[title="Add row below"]', 'expected' => 8, ], [ 'description' => 'remove a row', - 'click' => 'typo3-backend-table-wizard tbody tr:first-child > th button[title="Remove row"]', + 'click' => 'typo3-backend-table-wizard tbody tr:first-child > td button[title="Remove row"]', 'expected' => 6, ], ]; @@ -122,35 +122,35 @@ final class ElementsBasicInputTextTableCest extends AbstractElementsBasicCest $formSection = $this->getTable($I); $formSection->getLocationOnScreenOnceScrolledIntoView(); - $I->fillField('input[name="TABLE[c][0][0]"]', 'Test Column 1'); - $I->fillField('input[name="TABLE[c][0][1]"]', 'Test Column 2'); + $I->fillField('input[data-row="0"][data-col="0"]', 'Test Column 1'); + $I->fillField('input[data-row="0"][data-col="1"]', 'Test Column 2'); $I->amGoingTo('move column to the right'); - $textOriginColumn = $I->grabValueFrom('input[name="TABLE[c][0][0]"]'); + $textOriginColumn = $I->grabValueFrom('input[data-row="0"][data-col="0"]'); $I->click('typo3-backend-table-wizard tr > th:nth-child(2) button[title="Move right"]'); $I->click(self::$saveButtonLink); - $textNewColumn = $I->grabValueFrom('input[name="TABLE[c][0][1]"]'); + $textNewColumn = $I->grabValueFrom('input[data-row="0"][data-col="1"]'); $I->assertEquals($textOriginColumn, $textNewColumn); $I->amGoingTo('move column to the left'); - $textOriginColumn = $I->grabValueFrom('input[name="TABLE[c][0][1]"]'); + $textOriginColumn = $I->grabValueFrom('input[data-row="0"][data-col="1"]'); $I->click('typo3-backend-table-wizard tr > th:nth-child(3) button[title="Move left"]'); $I->click(self::$saveButtonLink); - $textNewColumn = $I->grabValueFrom('input[name="TABLE[c][0][0]"]'); + $textNewColumn = $I->grabValueFrom('input[data-row="0"][data-col="0"]'); $I->assertEquals($textOriginColumn, $textNewColumn); $I->amGoingTo('move row down'); - $textOriginColumn = $I->grabValueFrom('input[name="TABLE[c][0][0]"]'); - $I->click('typo3-backend-table-wizard tbody tr:first-child > th button[title="Move down"]'); + $textOriginColumn = $I->grabValueFrom('input[data-row="0"][data-col="0"]'); + $I->click('typo3-backend-table-wizard tbody tr:first-child > td button[title="Move down"]'); $I->click(self::$saveButtonLink); - $textNewColumn = $I->grabValueFrom('input[name="TABLE[c][1][0]"]'); + $textNewColumn = $I->grabValueFrom('input[data-row="1"][data-col="0"]'); $I->assertEquals($textOriginColumn, $textNewColumn); $I->amGoingTo('move row up'); - $textOriginColumn = $I->grabValueFrom('input[name="TABLE[c][2][0]"]'); - $I->click('typo3-backend-table-wizard tbody tr:nth-child(3) > th button[title="Move up"]'); + $textOriginColumn = $I->grabValueFrom('input[data-row="2"][data-col="0"]'); + $I->click('typo3-backend-table-wizard tbody tr:nth-child(3) > td button[title="Move up"]'); $I->click(self::$saveButtonLink); - $textNewColumn = $I->grabValueFrom('input[name="TABLE[c][1][0]"]'); + $textNewColumn = $I->grabValueFrom('input[data-row="1"][data-col="0"]'); $I->assertEquals($textOriginColumn, $textNewColumn); } -- GitLab