diff --git a/includes/sanitizers/class-amp-form-sanitizer.php b/includes/sanitizers/class-amp-form-sanitizer.php index 223cb826042..96901aba8e5 100644 --- a/includes/sanitizers/class-amp-form-sanitizer.php +++ b/includes/sanitizers/class-amp-form-sanitizer.php @@ -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' );