diff options
author | vipsoft <vipsoft@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2009-08-09 01:19:47 +0400 |
---|---|---|
committer | vipsoft <vipsoft@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2009-08-09 01:19:47 +0400 |
commit | 57d1ec9a87305ad47ed9d0e7eaae08ac74f2b98e (patch) | |
tree | c42ad5e2f0261562243158e4cbcdf454d6042b97 /core/Common.php | |
parent | b78aaa13d369d967a739ffffe1e15cd385522305 (diff) |
refs #911 - simplifying regexps; preg_quote() where needed
Diffstat (limited to 'core/Common.php')
-rw-r--r-- | core/Common.php | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/core/Common.php b/core/Common.php index f985a0e526..4215334237 100644 --- a/core/Common.php +++ b/core/Common.php @@ -287,7 +287,7 @@ class Piwik_Common */ static public function isValidFilename($filename) { - return (0 !== preg_match("/(^[a-zA-Z0-9]+([a-zA-Z\_0-9\.-]*))$/" , $filename)); + return (0 !== preg_match('/(^[a-zA-Z0-9]+([a-zA-Z_0-9.-]*))$/', $filename)); } /** @@ -300,7 +300,7 @@ class Piwik_Common */ static function isLookLikeUrl( $url ) { - return preg_match('/^(ftp|news|http|https)?:\/\/(.*)$/', $url, $matches) !== 0 + return preg_match('~^(ftp|news|http|https)?://(.*)$~', $url, $matches) !== 0 && strlen($matches[2]) > 0; } @@ -613,7 +613,7 @@ class Piwik_Common $browserLang = preg_replace($replacementPatterns, '', $browserLang); $browserLang = preg_replace('/((^|,)chrome:.*)/', '', $browserLang, 1); // Firefox bug - $browserLang = preg_replace('/(,)(?:en-securid,)|(?:(^|,)en-securid(,|$))/', '\\1', $browserLang, 1); // unregistered language tag + $browserLang = preg_replace('/(,)(?:en-securid,)|(?:(^|,)en-securid(,|$))/', '$1', $browserLang, 1); // unregistered language tag $browserLang = str_replace('sr-sp', 'sr-rs', $browserLang); // unofficial (proposed) code in the wild } @@ -680,7 +680,7 @@ class Piwik_Common } } - if(!empty($validCountries) && preg_match_all("/[-]([a-z]{2})/", $browserLanguage, $matches, PREG_SET_ORDER)) + if(!empty($validCountries) && preg_match_all('/[-]([a-z]{2})/', $browserLanguage, $matches, PREG_SET_ORDER)) { foreach($matches as $parts) { @@ -706,7 +706,7 @@ class Piwik_Common { // assumes language preference is sorted; // does not handle language-script-region tags or language range (*) - if(!empty($validLanguages) && preg_match_all("/(?:^|,)([a-z]{2,3})([-][a-z]{2})?/", $browserLanguage, $matches, PREG_SET_ORDER)) + if(!empty($validLanguages) && preg_match_all('/(?:^|,)([a-z]{2,3})([-][a-z]{2})?/', $browserLanguage, $matches, PREG_SET_ORDER)) { foreach($matches as $parts) { |