magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.4k stars 9.29k forks source link

When using 'mage/storage'.post() in admin and passing 'form_key' in json encoded, condition isn't fulfilled #37855

Open robertd-eclipse opened 11 months ago

robertd-eclipse commented 11 months ago

When sending data

JSON.stringify({
...
        form_key: form_key
...
})

in 'mage/storage'.post(url, data) to the REST endpoint

the form_key isn't found because it is searching for 'form_key=' and not 'form_key' https://github.com/magento/magento2/blob/0a834cce01c3d924d450c9a71123d9ac6de68b62/lib/web/mage/backend/bootstrap.js#L46

and it is adding to the encoded json string '{}'&form_key=xyz, what makes an exception in [64 line] \Magento\Framework\Webapi\Rest\Request\Deserializer\decodedBody

To bypass this I have added in data

JSON.stringify({
...
       'form_key=': form_key
...
})

is there a reason why in lib/web/mage/backend/bootstrap.js#L46 it is comparing 'form_key=' and not just 'form_key'?

m2-assistant[bot] commented 11 months ago

Hi @robertd-eclipse. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

m2-assistant[bot] commented 10 months ago

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

github-jira-sync-bot commented 10 months ago

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

engcom-November commented 10 months ago

Hello @robertd-eclipse,

Thank you for the report and collaboration!

By looking into the codebase it seems the issue can be reproduced. Hence confirming the issue.

Thank you.

github-jira-sync-bot commented 10 months ago

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

github-jira-sync-bot commented 10 months ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-9586 is successfully created for this GitHub issue.

m2-assistant[bot] commented 10 months ago

:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.