Replace strstr with strpos because it’s faster
authorLukas Kämmerling <kontakt@lukas-kaemmerling.de>
Thu, 29 Mar 2018 06:31:03 +0000 (08:31 +0200)
committerTim Düsterhus <timwolla@googlemail.com>
Tue, 1 May 2018 13:19:32 +0000 (15:19 +0200)
Signed-off-by: Lukas Kämmerling <kontakt@lukas-kaemmerling.de>
wcfsetup/install/files/lib/action/PaypalCallbackAction.class.php
wcfsetup/install/files/lib/system/WCF.class.php
wcfsetup/install/files/lib/util/HeaderUtil.class.php
wcfsetup/install/files/lib/util/ImageUtil.class.php

index 21b67401e6b46dcbd4299cad6a62c699f253b8e7..f9f59f2758fe312ffc0a67acd5ed1bae446d0bb5 100644 (file)
@@ -43,7 +43,7 @@ class PaypalCallbackAction extends AbstractAction {
                                throw new SystemException('connection to paypal.com failed: ' . $e->getMessage());
                        }
                        
-                       if (strstr($content, "VERIFIED") === false) {
+                       if (strpos($content, "VERIFIED") === false) {
                                throw new SystemException('request not validated');
                        }
                        
index 729873735b6d0651e4cf886d41384ae149879fa0..c9c167b611aa57a97f4e64af51258604d423c23e 100644 (file)
@@ -285,8 +285,8 @@ class WCF {
                        // we'll just gzip the output of the exception to prevent them from tampering.
                        // This part is copied from `HeaderUtil` in order to isolate the exception handler!
                        if (HTTP_ENABLE_GZIP && !defined('HTTP_DISABLE_GZIP')) {
-                               if (function_exists('gzcompress') && !@ini_get('zlib.output_compression') && !@ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
-                                       if (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip')) {
+                               if (function_exists('gzcompress') && !@ini_get('zlib.output_compression') && !@ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false) {
+                                       if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip') !== false) {
                                                @header('Content-Encoding: x-gzip');
                                        }
                                        else {
index 50c71f97b04cbde5c66740c1d5e87692b64c2c79..74a499f3b6a89c3148aa1f391ff3664a048e1b7d 100644 (file)
@@ -64,10 +64,10 @@ final class HeaderUtil {
                }
                
                if (HTTP_ENABLE_GZIP && !defined('HTTP_DISABLE_GZIP')) {
-                       if (function_exists('gzcompress') && !@ini_get('zlib.output_compression') && !@ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
+                       if (function_exists('gzcompress') && !@ini_get('zlib.output_compression') && !@ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false) {
                                self::$enableGzipCompression = true;
                                
-                               if (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip')) {
+                               if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip') !== false) {
                                        @header('Content-Encoding: x-gzip');
                                }
                                else {
index c148843e59d3ec3d201da40709109f0499334589..9be2cbd134b95b286ffaa66c16c98d89d3638a6e 100644 (file)
@@ -26,7 +26,7 @@ final class ImageUtil {
                $content = str_replace('description', '', $content);
                
                // search for javascript
-               if (strstr($content, 'script') || strstr($content, 'javascript') || strstr($content, 'expression(')) return false;
+               if (strpos($content, 'script') !== false || strpos($content, 'javascript') !== false || strpos($content, 'expression(') !== false) return false;
                
                return true;
        }