aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/includes/acp/acp_bbcodes.php8
-rw-r--r--phpBB/includes/cache.php2
-rw-r--r--phpBB/includes/functions.php16
-rw-r--r--phpBB/includes/functions_user.php4
-rw-r--r--phpBB/includes/search/fulltext_mysql.php2
5 files changed, 21 insertions, 11 deletions
diff --git a/phpBB/includes/acp/acp_bbcodes.php b/phpBB/includes/acp/acp_bbcodes.php
index b046424790..b6bbbdc0cf 100644
--- a/phpBB/includes/acp/acp_bbcodes.php
+++ b/phpBB/includes/acp/acp_bbcodes.php
@@ -317,13 +317,7 @@ class acp_bbcodes
$bbcode_tpl = trim($bbcode_tpl);
$utf8 = strpos($bbcode_match, 'INTTEXT') !== false;
- // make sure we have utf8 support
- // PHP may not be linked with the bundled PCRE lib and instead with an older version
- $utf8_pcre_properties = false;
- if (@preg_match('/\p{L}/u', 'a') !== false)
- {
- $utf8_pcre_properties = true;
- }
+ $utf8_pcre_properties = pcre_utf8_support();
$fp_match = preg_quote($bbcode_match, '!');
$fp_replace = preg_replace('#^\[(.*?)\]#', '[$1:$uid]', $bbcode_match);
diff --git a/phpBB/includes/cache.php b/phpBB/includes/cache.php
index 7c739fa600..1986f021c6 100644
--- a/phpBB/includes/cache.php
+++ b/phpBB/includes/cache.php
@@ -82,7 +82,7 @@ class cache extends acm
$result = $db->sql_query($sql);
$censors = array();
- $unicode = (@preg_match('/\p{L}/u', 'a') !== false) ? true : false;
+ $unicode = pcre_utf8_support();
while ($row = $db->sql_fetchrow($result))
{
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 48a9661347..285c3938c1 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -4507,3 +4507,19 @@ function phpbb_user_session_handler()
return;
}
+
+/**
+* Check if PCRE has UTF-8 support
+* PHP may not be linked with the bundled PCRE lib and instead with an older version
+*
+* @return bool Returns true if PCRE (the regular expressions library) supports UTF-8 encoding
+*/
+function pcre_utf8_support()
+{
+ static $utf8_pcre_properties = null;
+ if (is_null($utf8_pcre_properties))
+ {
+ $utf8_pcre_properties = (@preg_match('/\p{L}/u', 'a') !== false);
+ }
+ return $utf8_pcre_properties;
+}
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 9ab9d6d568..b99393d24a 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -1490,7 +1490,7 @@ function validate_username($username, $allowed_username = false)
$mbstring = $pcre = false;
// generic UTF-8 character types supported?
- if (@preg_match('/\p{L}/u', 'a') !== false)
+ if (pcre_utf8_support())
{
$pcre = true;
}
@@ -1626,7 +1626,7 @@ function validate_password($password)
$pcre = $mbstring = false;
// generic UTF-8 character types supported?
- if (@preg_match('/\p{L}/u', 'a') !== false)
+ if (pcre_utf8_support())
{
$upp = '\p{Lu}';
$low = '\p{Ll}';
diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php
index 22aeca7fee..9660fd6986 100644
--- a/phpBB/includes/search/fulltext_mysql.php
+++ b/phpBB/includes/search/fulltext_mysql.php
@@ -43,7 +43,7 @@ class fulltext_mysql extends search_backend
$this->word_length = array('min' => $config['fulltext_mysql_min_word_len'], 'max' => $config['fulltext_mysql_max_word_len']);
// PHP may not be linked with the bundled PCRE lib and instead with an older version
- if (@preg_match('/\p{L}/u', 'a') !== false)
+ if (pcre_utf8_support())
{
$this->pcre_properties = true;
}