{
global $aliaspage, $autoalias_max_words;
static $pairs;
+ $preg_u = get_preg_u();
if (! isset($pairs)) {
$pairs = array();
$matches = array();
$count = 0;
$max = max($autoalias_max_words, 0);
- if (preg_match_all('/' . $pattern . '/x', $postdata, $matches, PREG_SET_ORDER)) {
+ if (preg_match_all('/' . $pattern . '/x' . get_preg_u(), $postdata,
+ $matches, PREG_SET_ORDER)) {
foreach($matches as $key => $value) {
if ($count == $max) break;
$name = trim($value[1]);
return FALSE;
}
+/**
+ * Return 'u' (PCRE_UTF8) if PHP7+ and UTF-8.
+ */
+function get_preg_u() {
+ static $utf8u; // 'u'(PCRE_UTF8) or ''
+ if (! isset($utf8u)) {
+ if (version_compare('7.0.0', PHP_VERSION, '<=')
+ && defined('PKWK_UTF8_ENABLE')) {
+ $utf8u = 'u';
+ } else {
+ $utf8u = '';
+ }
+ }
+ return $utf8u;
+}
+
//// Compat ////
// is_a -- Returns TRUE if the object is of this class or has this class as one of its parents
$InterWikiName = '(\[\[)?((?:(?!\s|:|\]\]).)+):(.+)(?(1)\]\])';
// 注釈
-$NotePattern = '/\(\(((?:(?>(?:(?!\(\()(?!\)\)(?:[^\)]|$)).)+)|(?R))*)\)\)/x';
+$NotePattern = '/\(\(((?:(?>(?:(?!\(\()(?!\)\)(?:[^\)]|$)).)+)|(?R))*)\)\)/x'
+ . get_preg_u();
/////////////////////////////////////////////////
// 初期設定(ユーザ定義ルール読み込み)
$this->page = $page;
$this->result = array();
- $string = preg_replace_callback('/' . $this->pattern . '/x',
+ $string = preg_replace_callback('/' . $this->pattern . '/x' . get_preg_u(),
array(& $this, 'replace'), $string);
$arr = explode("\x08", make_line_rules(htmlsc($string)));
function get_objects($string, $page)
{
$matches = $arr = array();
- preg_match_all('/' . $this->pattern . '/x', $string, $matches, PREG_SET_ORDER);
+ preg_match_all('/' . $this->pattern . '/x' . get_preg_u(),
+ $string, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$obj = $this->get_converter($match);
if ($obj->set($match, $page) !== FALSE) {
// Re-get true plugin name and patameters (for PHP 4.1.2)
$matches = array();
- if (preg_match('/^' . $this->pattern . '/x', $all, $matches)
+ if (preg_match('/^' . $this->pattern . '/x' . get_preg_u(), $all, $matches)
&& $matches[1] != $this->plain)
list(, $this->plain, $name, $this->param) = $matches;