magento2
magento2 copied to clipboard
URLs should not contains reserved characters according to RFC 3986
Description (*)
This PR fixes the RFC 3986 which forbids to use reserved characters in URLs such as a comma.
Related Pull Requests
Manual testing scenarios (*)
- Use the URL :
http://magento2.adobe/encoding/with/longer/url/
- Encode this URL with the
Magento\Framework\Url\Encoder::encode
method - Note that the base64 encoded URL contains a comma :
aHR0cDovL21hZ2VudG8yLmFkb2JlL2VuY29kaW5nL3dpdGgvbG9uZ2VyL3VybC8,
- Use the native method rawurlencode from PHP on the result :
aHR0cDovL21hZ2VudG8yLmFkb2JlL2VuY29kaW5nL3dpdGgvbG9uZ2VyL3VybC8%2C
(please notice the %2C character which is the hexadecimal value for a comma, which is not allowed. - Decode this URL back :
http://magento2.adobe/encoding/with/longer/url/6
(a6
was added at the end of the URL because of the encoded value)
Questions or comments
In my understanding of the RFC, an URL can't contain a comma (or whatever reserved characters). However, Magento uses such character in the encode
method to remove the =
character from the base64 encoded value.
https://github.com/magento/magento2/blob/c6aeb6aef1eaf849aadeeadedd63ac6cd3dc23fc/lib/internal/Magento/Framework/Url/Encoder.php#L18
This PR replaces the comma value by a tilde as this is an unreserved character allowed for an URL and which will not be transformed in the rawurlencode
method.
Contribution checklist (*)
- [ ] Pull request has a meaningful description of its purpose
- [ ] All commits are accompanied by meaningful commit messages
- [ ] All new or changed code is covered with unit/integration tests (if applicable)
- [ ] README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
- [ ] All automated tests passed successfully (all builds are green)
Hi @MeCapron. Thank you for your contribution Here are some useful tips how you can test your changes using Magento test environment. Add the comment under your pull request to deploy test or vanilla Magento instance:
-
@magento give me test instance
- deploy test instance based on PR changes -
@magento give me 2.4-develop instance
- deploy vanilla Magento instance
:exclamation: Automated tests can be triggered manually with an appropriate comment:
-
@magento run all tests
- run or re-run all required tests against the PR changes -
@magento run <test-build(s)>
- run or re-run specific test build(s) For example:@magento run Unit Tests
<test-build(s)>
is a comma-separated list of build names. Allowed build names are:
-
Database Compare
-
Functional Tests CE
-
Functional Tests EE
, -
Functional Tests B2B
-
Integration Tests
-
Magento Health Index
-
Sample Data Tests CE
-
Sample Data Tests EE
-
Sample Data Tests B2B
-
Static Tests
-
Unit Tests
-
WebAPI Tests
-
Semantic Version Checker
You can find more information about the builds here
:information_source: Run only required test builds during development. Run all test builds before sending your pull request for review.
For more details, review the Magento Contributor Guide documentation.
:warning: According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
:clock10: You can find the schedule on the Magento Community Calendar page.
:telephone_receiver: The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.
:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel
@magento run all tests
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
@magento run all tests
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
@magento run all tests
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
@magento run all tests
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
@magento run Functional Tests EE, Functional Tests B2B, Functional Tests CE
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
@magento run Functional Tests CE
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
@magento give me 2.4-develop instance
Hi @engcom-Lima. Thank you for your request. I'm working on Magento instance for you.
Hi @engcom-Lima, here is your Magento Instance: https://4a801c663c443bb11eff8c1bfc0e8ef8.instances.magento-community.engineering Admin access: https://4a801c663c443bb11eff8c1bfc0e8ef8.instances.magento-community.engineering/admin_da66 Login: 722066f1 Password: d86e7e8942f8
@magento create issue
:heavy_check_mark: Issue confirmed
Issue got reproduced in 2.4-develop branch.
Description: URLs should not contains reserved characters according to RFC 3986
Pre-requisite:
Fresh magento 2.4-develop
should be installed.
Steps to reproduce:
- Use the URL : http://magento2.adobe/encoding/with/longer/url/
- Encode this URL with the Magento\Framework\Url\Encoder::encode method
- Note that the base64 encoded URL contains a comma : aHR0cDovL21hZ2VudG8yLmFkb2JlL2VuY29kaW5nL3dpdGgvbG9uZ2VyL3VybC8,
- Use the native method rawurlencode from PHP on the result : aHR0cDovL21hZ2VudG8yLmFkb2JlL2VuY29kaW5nL3dpdGgvbG9uZ2VyL3VybC8%2C (please notice the %2C character which is the hexadecimal value for a comma, which is not allowed.
- Decode this URL back : http://magento2.adobe/encoding/with/longer/url/6 (a 6 was added at the end of the URL because of the encoded value)
After PR changes: This PR fixes the RFC 3986 which forbids to use reserved characters in URLs such as a comma.
Additionally tested:
- Created order from frontend.
- From admin, created invoice.
- Created shipping.
- Created credit memo,
- Reordered the product.
PR is working fine. Hence, moving it to Merge in progress.
@magento give me 2.4.4 instance
Hi @engcom-Lima. Thank you for your request. I'm working on Magento instance for you.
Hi @engcom-Lima, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.