mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[ticket/9574] Add pcre_utf8_support() function
Refactor the check for PCRE UTF-8 support into a new pcre_utf8_support() function. PHPBB3-9574
This commit is contained in:
parent
eda9fbbb63
commit
6b4d0a2542
5 changed files with 21 additions and 11 deletions
|
@ -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);
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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}';
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue