Skip to content

Commit

Permalink
Fix ampproject#1349. Detect http(s) and format it.
Browse files Browse the repository at this point in the history
Detect if action URL in the form doesn't start with http(s) and format it properly.
  • Loading branch information
ricardobrg authored Aug 22, 2018
1 parent fae8ab9 commit d53edc7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions includes/sanitizers/class-amp-form-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ public function sanitize() {
} 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;
if ( ! preg_match( '#^(https?:)?//#', $action_url ) ) {
$action_url = esc_url_raw( '//' . $_SERVER['HTTP_HOST'] . $action_url );
}
}
$xhr_action = $node->getAttribute( 'action-xhr' );
Expand Down

0 comments on commit d53edc7

Please sign in to comment.