From 03c66dd29808f38b328c036fa4343beefb146e1c Mon Sep 17 00:00:00 2001 From: dmatt Date: Fri, 21 May 2021 15:52:38 -0700 Subject: [PATCH 1/2] Check that host key exists before using in dsq_filter_rest_url --- disqus/admin/class-disqus-admin.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/disqus/admin/class-disqus-admin.php b/disqus/admin/class-disqus-admin.php index f6cdb7a..03483db 100755 --- a/disqus/admin/class-disqus-admin.php +++ b/disqus/admin/class-disqus-admin.php @@ -159,15 +159,17 @@ public function enqueue_scripts() { */ public function dsq_filter_rest_url( $rest_url ) { $rest_url_parts = parse_url( $rest_url ); - $rest_host = $rest_url_parts['host']; - if ( array_key_exists( 'port', $rest_url_parts ) ) { - $rest_host .= ':' . $rest_url_parts['port']; - } + if ( array_key_exists( 'host', $rest_url_parts ) ) { + $rest_host = $rest_url_parts['host']; + if ( array_key_exists( 'port', $rest_url_parts ) ) { + $rest_host .= ':' . $rest_url_parts['port']; + } - $current_host = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : $rest_host; + $current_host = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : $rest_host; - if ( $rest_host !== $current_host ) { - $rest_url = preg_replace( '/' . $rest_host . '/', $current_host, $rest_url, 1 ); + if ( $rest_host !== $current_host ) { + $rest_url = preg_replace( '/' . $rest_host . '/', $current_host, $rest_url, 1); + } } return $rest_url; From dc4ea779ffc00204c92b28412c68bdb48b5494e0 Mon Sep 17 00:00:00 2001 From: dmatt Date: Tue, 25 May 2021 12:24:46 -0700 Subject: [PATCH 2/2] Lint: add space before function call closing parenthesis --- disqus/admin/class-disqus-admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disqus/admin/class-disqus-admin.php b/disqus/admin/class-disqus-admin.php index 03483db..050d6a8 100755 --- a/disqus/admin/class-disqus-admin.php +++ b/disqus/admin/class-disqus-admin.php @@ -168,7 +168,7 @@ public function dsq_filter_rest_url( $rest_url ) { $current_host = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : $rest_host; if ( $rest_host !== $current_host ) { - $rest_url = preg_replace( '/' . $rest_host . '/', $current_host, $rest_url, 1); + $rest_url = preg_replace( '/' . $rest_host . '/', $current_host, $rest_url, 1 ); } }