From f05c228f1d74bd4c004f29de4c573ff65dfabef5 Mon Sep 17 00:00:00 2001 From: jo Date: Tue, 12 Oct 2021 11:09:46 +0200 Subject: [PATCH] Put regex rules between single quotes --- legacy/application/common/CORSHelper.php | 2 +- legacy/application/common/Database.php | 2 +- legacy/application/forms/SmartBlockCriteria.php | 6 +++--- legacy/application/models/Preference.php | 6 +++--- legacy/application/models/Webstream.php | 12 ++++++------ legacy/application/models/airtime/CcFiles.php | 2 +- legacy/application/views/helpers/VersionNotify.php | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/legacy/application/common/CORSHelper.php b/legacy/application/common/CORSHelper.php index 2bde8d914..56ca627ba 100644 --- a/legacy/application/common/CORSHelper.php +++ b/legacy/application/common/CORSHelper.php @@ -8,7 +8,7 @@ class CORSHelper $origin = $request->getHeader('Origin'); $allowedOrigins = self::getAllowedOrigins($request); - if ((!(preg_match("/https?:\/\/localhost/", $origin) === 1)) && ($origin != '') + if ((!(preg_match('/https?:\/\/localhost/', $origin) === 1)) && ($origin != '') && (!in_array($origin, $allowedOrigins)) ) { //Don't allow CORS from other domains to prevent XSS. diff --git a/legacy/application/common/Database.php b/legacy/application/common/Database.php index 650e02aca..0a9c36341 100644 --- a/legacy/application/common/Database.php +++ b/legacy/application/common/Database.php @@ -69,7 +69,7 @@ class Application_Common_Database $new_params[$k] = $new_params[$v]; } else { foreach (range(1, $matches_count) as $i) { - preg_replace("/{$k}(\D)/", "{$k}{$i}${1}", $sql, 1); + preg_replace('/' . $k . '(\D)/', "{$k}{$i}${1}", $sql, 1); $new_params[$k . $i] = $v; } } diff --git a/legacy/application/forms/SmartBlockCriteria.php b/legacy/application/forms/SmartBlockCriteria.php index 64071476d..0166965bd 100644 --- a/legacy/application/forms/SmartBlockCriteria.php +++ b/legacy/application/forms/SmartBlockCriteria.php @@ -850,7 +850,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm $column = CcFilesPeer::getTableMap()->getColumnByPhpName($criteria2PeerMap[$d['sp_criteria_field']]); // validation on type of column if (in_array($d['sp_criteria_field'], ['length', 'cuein', 'cueout'])) { - if (!preg_match("/^(\d{2}):(\d{2}):(\d{2})/", $d['sp_criteria_value'])) { + if (!preg_match('/^(\d{2}):(\d{2}):(\d{2})/', $d['sp_criteria_value'])) { $element->addError(_("'Length' should be in '00:00:00' format")); $isValid = false; } @@ -868,7 +868,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm $isValid = false; } } else { - if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_value'])) { + if (!preg_match('/(\d{4})-(\d{2})-(\d{2})/', $d['sp_criteria_value'])) { $element->addError(_('The value should be in timestamp format (e.g. 0000-00-00 or 0000-00-00 00:00:00)')); $isValid = false; } else { @@ -893,7 +893,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm $isValid = false; } } else { - if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_extra'])) { + if (!preg_match('/(\d{4})-(\d{2})-(\d{2})/', $d['sp_criteria_extra'])) { $element->addError(_('The value should be in timestamp format (e.g. 0000-00-00 or 0000-00-00 00:00:00)')); $isValid = false; } else { diff --git a/legacy/application/models/Preference.php b/legacy/application/models/Preference.php index 4efef23ae..25c720566 100644 --- a/legacy/application/models/Preference.php +++ b/legacy/application/models/Preference.php @@ -913,7 +913,7 @@ class Application_Model_Preference public static function SetLatestVersion($version) { - $pattern = "/^[0-9]+\.[0-9]+\.[0-9]+/"; + $pattern = '/^[0-9]+\.[0-9]+\.[0-9]+/'; if (preg_match($pattern, $version)) { self::setValue('latest_version', $version); } @@ -932,8 +932,8 @@ class Application_Model_Preference public static function SetLatestLink($link) { $pattern = '#^(http|https|ftp)://' . - "([a-zA-Z0-9]+\.)*[a-zA-Z0-9]+" . - "(/[a-zA-Z0-9\-\.\_\~\:\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=]+)*/?$#"; + '([a-zA-Z0-9]+\.)*[a-zA-Z0-9]+' . + '(/[a-zA-Z0-9\-\.\_\~\:\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=]+)*/?$#'; if (preg_match($pattern, $link)) { self::setValue('latest_link', $link); } diff --git a/legacy/application/models/Webstream.php b/legacy/application/models/Webstream.php index 2e534073e..7de28c0cf 100644 --- a/legacy/application/models/Webstream.php +++ b/legacy/application/models/Webstream.php @@ -127,7 +127,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable $di = null; $length = $parameters['length']; - $result = preg_match("/^(?:([0-9]{1,2})h)?\s*(?:([0-9]{1,2})m)?$/", $length, $matches); + $result = preg_match('/^(?:([0-9]{1,2})h)?\s*(?:([0-9]{1,2})m)?$/', $length, $matches); $invalid_date_interval = false; if ($result == 1 && count($matches) == 2) { @@ -171,7 +171,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable //simple validator that checks to make sure that the url starts with //http(s), //and that the domain is at least 1 letter long - $result = preg_match("/^(http|https):\/\/.+/", $url, $matches); + $result = preg_match('/^(http|https):\/\/.+/', $url, $matches); $mime = null; $mediaUrl = null; @@ -189,7 +189,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable } $mediaUrl = self::getMediaUrl($url, $mime, $content_length_found); - if (preg_match("/(x-mpegurl)|(xspf\+xml)|(pls\+xml)|(x-scpls)/", $mime)) { + if (preg_match('/(x-mpegurl)|(xspf\+xml)|(pls\+xml)|(x-scpls)/', $mime)) { list($mime, $content_length_found) = self::discoverStreamMime($mediaUrl); } } catch (Exception $e) { @@ -318,11 +318,11 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable { if (preg_match('/x-mpegurl/', $mime)) { $media_url = self::getM3uUrl($url); - } elseif (preg_match("/xspf\+xml/", $mime)) { + } elseif (preg_match('/xspf\+xml/', $mime)) { $media_url = self::getXspfUrl($url); - } elseif (preg_match("/pls\+xml/", $mime) || preg_match('/x-scpls/', $mime)) { + } elseif (preg_match('/pls\+xml/', $mime) || preg_match('/x-scpls/', $mime)) { $media_url = self::getPlsUrl($url); - } elseif (preg_match("/(mpeg|ogg|audio\/aacp|audio\/aac)/", $mime)) { + } elseif (preg_match('/(mpeg|ogg|audio\/aacp|audio\/aac)/', $mime)) { if ($content_length_found) { throw new Exception(_('Invalid webstream - This appears to be a file download.')); } diff --git a/legacy/application/models/airtime/CcFiles.php b/legacy/application/models/airtime/CcFiles.php index d685a1e11..9773f54c0 100644 --- a/legacy/application/models/airtime/CcFiles.php +++ b/legacy/application/models/airtime/CcFiles.php @@ -483,7 +483,7 @@ class CcFiles extends BaseCcFiles private static function stripTimeStampFromYearTag($metadata) { if (isset($metadata['year'])) { - if (preg_match("/^(\d{4})-(\d{2})-(\d{2})(?:\s+(\d{2}):(\d{2}):(\d{2}))?$/", $metadata['year'])) { + if (preg_match('/^(\d{4})-(\d{2})-(\d{2})(?:\s+(\d{2}):(\d{2}):(\d{2}))?$/', $metadata['year'])) { $metadata['year'] = substr($metadata['year'], 0, 4); } } diff --git a/legacy/application/views/helpers/VersionNotify.php b/legacy/application/views/helpers/VersionNotify.php index 48cbcd6e5..2968b45df 100644 --- a/legacy/application/views/helpers/VersionNotify.php +++ b/legacy/application/views/helpers/VersionNotify.php @@ -100,7 +100,7 @@ class Airtime_View_Helper_VersionNotify extends Zend_View_Helper_Abstract $parts = []; if (!$isGit) { - $parts = preg_split("/(\.|-)/", $version); + $parts = preg_split('/(\.|-)/', $version); } if (count($parts) < 3) { $parts = [0, 0, 0];