Force https for page logo for secure pages
authorAlexander Ebert <ebert@woltlab.com>
Thu, 18 May 2017 12:31:51 +0000 (14:31 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 18 May 2017 12:31:51 +0000 (14:31 +0200)
See #2273

wcfsetup/install/files/lib/data/style/ActiveStyle.class.php

index 38903dfc4857b8b2af52b5209f8782239a1ebd52..77f61f33f349626ea7f811b3ea75d01b48137bb5 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\data\style;
 use wcf\data\DatabaseObjectDecorator;
+use wcf\system\request\RouteHandler;
 use wcf\system\WCF;
 
 /**
@@ -27,7 +28,12 @@ class ActiveStyle extends DatabaseObjectDecorator {
         * @return      string
         */
        public function getImage($image) {
-               if (preg_match('~^https?://~', $image)) {
+               if (preg_match('~^(https?)://~', $image, $matches)) {
+                       // rewrite protocol
+                       if ($matches[1] === 'http' && RouteHandler::secureConnection()) {
+                               return 'https' . mb_substr($image, 4);
+                       }
+                       
                        return $image;
                }