-
Notifications
You must be signed in to change notification settings - Fork 382
Description
Bug Description
When a form element has a relative URL (such as ../) or a query (such as ?foo=bar) for the action attribute, the value is incorrectly sanitized and a malformed URL is produced.
For example, given that the request URL is https://example.org/about/?amp with Transitional mode active, the following can be observed:
action |
Sanitized action |
Expected action |
|---|---|---|
../ |
//example.org/about/?amp/__/&_wp_amp_action_xhr_converted=1& |
//example.org/?amp&_wp_amp_action_xhr_converted=1 |
?foo=bar |
//example.org/about?amp?foo=bar&_wp_amp_action_xhr_converted=1& |
//example.org/about/?amp&foo=bar&_wp_amp_action_xhr_converted=1 |
This is also reproducible in Standard mode.
Do note that actions with relative anchor tags (eg. #foo) are correctly converted, which was fixed by #4003.
Steps to reproduce
-
Activate Transitional mode
-
Create a post and add a Custom HTML block with the following content:
<form method="post" action="../"></form>
<form method="post" action="?foo=bar"></form> -
View the AMP version of the post
-
Given that the current URL is
https://example.org/about/?amp, the following malformedaction-xhrURL values for eachformelement can be observed:
<form method="post" action-xhr="//example.com/about/?amp/__/&_wp_amp_action_xhr_converted=1&">...</form>
<form method="post" action-xhr="//example.com/about/?amp?foo=bar&_wp_amp_action_xhr_converted=1&">...</form>Screenshots
Additional context
- WordPress version:
- Plugin version:
- Gutenberg plugin version (if applicable):
- AMP plugin template mode:
- PHP version:
- OS:
- Browser: [e.g. chrome, safari]
- Device: [e.g. iPhone6]
Do not alter or remove anything below. The following sections will be managed by moderators only.