Add more Strings::isHex() checks to photos
authorPhilipp Holzer <admin+github@philipp.info>
Thu, 30 May 2019 08:30:15 +0000 (10:30 +0200)
committerPhilipp Holzer <admin+github@philipp.info>
Thu, 30 May 2019 08:30:15 +0000 (10:30 +0200)
mod/photos.php
src/Util/Strings.php

index 6a84e61..0769374 100644 (file)
@@ -188,6 +188,9 @@ function photos_post(App $a)
        }
 
        if ($a->argc > 3 && $a->argv[2] === 'album') {
+               if (!Strings::isHex($a->argv[3])) {
+                       $a->internalRedirect();
+               }
                $album = hex2bin($a->argv[3]);
 
                if ($album === L10n::t('Profile Photos') || $album === 'Contact Photos' || $album === L10n::t('Contact Photos')) {
@@ -960,7 +963,7 @@ function photos_content(App $a)
                        return;
                }
 
-               $selname = $datum ? hex2bin($datum) : '';
+               $selname = Strings::isHex($datum) ? hex2bin($datum) : '';
 
                $albumselect = '';
 
index 14fbde8..88dd1d3 100644 (file)
@@ -40,7 +40,7 @@ class Strings
         */
     public static function isHex($hexCode)
     {
-           return @preg_match("/^[a-f0-9]{2,}$/i", $hexCode) && !(strlen($hexCode) & 1);
+           return !empty($hexCode) ? @preg_match("/^[a-f0-9]{2,}$/i", $hexCode) && !(strlen($hexCode) & 1) : false;
     }
 
     /**