mirror of
https://github.com/friendica/friendica
synced 2024-11-10 05:42:54 +00:00
Adding hexadecimal check for photos
see https://github.com/friendica/friendica/issues/6917#issuecomment-492798238
This commit is contained in:
parent
59bbb1ac99
commit
3de540d1d1
2 changed files with 16 additions and 0 deletions
|
@ -1027,6 +1027,10 @@ function photos_content(App $a)
|
|||
|
||||
// Display a single photo album
|
||||
if ($datatype === 'album') {
|
||||
// if $datum is not a valid hex, redirect to the default page
|
||||
if (!Strings::isHex($datum)) {
|
||||
$a->internalRedirect();
|
||||
}
|
||||
$album = hex2bin($datum);
|
||||
|
||||
$total = 0;
|
||||
|
|
|
@ -31,6 +31,18 @@ class Strings
|
|||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks, if the given string is a valid hexadecimal code
|
||||
*
|
||||
* @param string $hexCode
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isHex($hexCode)
|
||||
{
|
||||
return @preg_match("/^[a-f0-9]{2,}$/i", $hexCode) && !(strlen($hexCode) & 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This is our primary input filter.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue