From fae8ab9c7ce18b280c1d304112e11fa13166d195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gon=C3=A7alves?= Date: Wed, 22 Aug 2018 01:22:01 -0300 Subject: [PATCH] Fix #1349 relative path issue in action Detect if action URL in the form is relative and format it properly --- includes/sanitizers/class-amp-form-sanitizer.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/sanitizers/class-amp-form-sanitizer.php b/includes/sanitizers/class-amp-form-sanitizer.php index 05c6252f0cc..223cb826042 100644 --- a/includes/sanitizers/class-amp-form-sanitizer.php +++ b/includes/sanitizers/class-amp-form-sanitizer.php @@ -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' );