forked from ampproject/amp-wp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ampproject#1349 relative path issue in action
Detect if action URL in the form is relative and format it properly
- Loading branch information
1 parent
274971c
commit fae8ab9
Showing
1 changed file
with
5 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,11 @@ public function sanitize() { | |
$action_url = esc_url_raw( '//' . $_SERVER['HTTP_HOST'] . wp_unslash( $_SERVER['REQUEST_URI'] ) ); // WPCS: ignore. input var okay, sanitization ok. | ||
} else { | ||
$action_url = $node->getAttribute( 'action' ); | ||
//check if action_url is a relative path and add the host to it | ||
preg_match('(^\/?[^\/].*)',$action_url,$matches); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ricardobrg
Author
Owner
|
||
if ($matches){ | ||
$action_url = '//' . $_SERVER['HTTP_HOST'] . $action_url; | ||
} | ||
} | ||
$xhr_action = $node->getAttribute( 'action-xhr' ); | ||
|
||
|
I suggest instead:
In actuality, we should also make sure that if it starts with
http:
that it should also get that stripped out, since forms must be submitted over HTTPS in AMP.