From 4e627a80c260b9ff0b3e4a8c3609e6b92f75bde8 Mon Sep 17 00:00:00 2001 From: Jonathan Clerc Date: Wed, 5 Oct 2016 12:49:33 +0200 Subject: [PATCH 1/2] Better content-type check As resources may have a header like `Content-Type: text/javascript;charset=UTF-8` --- src/Plugin/ProxifyPlugin.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Plugin/ProxifyPlugin.php b/src/Plugin/ProxifyPlugin.php index 15bd964..ede3a23 100644 --- a/src/Plugin/ProxifyPlugin.php +++ b/src/Plugin/ProxifyPlugin.php @@ -131,11 +131,14 @@ public function onCompleted(ProxyEvent $event){ $response = $event['response']; $str = $response->getContent(); - $content_type = $response->headers->get('content-type'); + $content_type = strtolower(trim($response->headers->get('content-type'))); // DO NOT do any proxification on .js files - if($content_type == 'text/javascript' || $content_type == 'application/javascript' || $content_type == 'application/x-javascript'){ - return; + $types = array('text/javascript', 'application/javascript', 'application/x-javascript'); + foreach($types as $type){ + if(strpos($content_type, $type) === 0){ + return; + } } // let's remove all frames?? does not protect against the frames created dynamically via javascript @@ -176,4 +179,4 @@ public function onCompleted(ProxyEvent $event){ } -?> \ No newline at end of file +?> From eae4b8e2e1e34f2bd7e3e06c1641645b9cb1ca48 Mon Sep 17 00:00:00 2001 From: Athlon1600 Date: Tue, 18 Oct 2016 13:41:23 -0500 Subject: [PATCH 2/2] Update ProxifyPlugin.php why not just use in_array method? http://php.net/manual/en/function.in-array.php --- src/Plugin/ProxifyPlugin.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Plugin/ProxifyPlugin.php b/src/Plugin/ProxifyPlugin.php index ede3a23..cc617d4 100644 --- a/src/Plugin/ProxifyPlugin.php +++ b/src/Plugin/ProxifyPlugin.php @@ -135,10 +135,8 @@ public function onCompleted(ProxyEvent $event){ // DO NOT do any proxification on .js files $types = array('text/javascript', 'application/javascript', 'application/x-javascript'); - foreach($types as $type){ - if(strpos($content_type, $type) === 0){ - return; - } + if(in_array($content_type, $types)){ + return; } // let's remove all frames?? does not protect against the frames created dynamically via javascript