Skip to content

Commit

Permalink
Fix #1349 relative path issue in action
Browse files Browse the repository at this point in the history
Detect if action URL in the form is relative and format it properly
  • Loading branch information
ricardobrg committed Aug 22, 2018
1 parent 274971c commit fae8ab9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions includes/sanitizers/class-amp-form-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
if ($matches){
$action_url = '//' . $_SERVER['HTTP_HOST'] . $action_url;
}
}
$xhr_action = $node->getAttribute( 'action-xhr' );

Expand Down

0 comments on commit fae8ab9

Please sign in to comment.