• R/O
  • HTTP
  • SSH
  • HTTPS

pukiwiki: Commit


Commit MetaInfo

Revisione4be5de275ab52f2d45f03e5477337c28d9bc286 (tree)
Time2020-08-21 02:15:36
Authorumorigu <umorigu@gmai...>
Commiterumorigu

Log Message

BugTrack/2512 preg_replace with PCRE_UTF8 option

Change Summary

Incremental Difference

--- a/lib/make_link.php
+++ b/lib/make_link.php
@@ -114,10 +114,19 @@ class InlineConverter
114114
115115 function convert($string, $page)
116116 {
117+ static $utf8u; // 'u'(PCRE_UTF8) or ''
118+ if (! isset($utf8u)) {
119+ if (version_compare('7.0.0', PHP_VERSION, '<=')
120+ && PKWK_UTF8_ENABLE) {
121+ $utf8u = 'u';
122+ } else {
123+ $utf8u = '';
124+ }
125+ }
117126 $this->page = $page;
118127 $this->result = array();
119128
120- $string = preg_replace_callback('/' . $this->pattern . '/x',
129+ $string = preg_replace_callback('/' . $this->pattern . '/x' . $utf8u,
121130 array(& $this, 'replace'), $string);
122131
123132 $arr = explode("\x08", make_line_rules(htmlsc($string)));
@@ -140,8 +149,18 @@ class InlineConverter
140149
141150 function get_objects($string, $page)
142151 {
152+ static $utf8u; // 'u'(PCRE_UTF8) or ''
153+ if (! isset($utf8u)) {
154+ if (version_compare('7.0.0', PHP_VERSION, '<=')
155+ && PKWK_UTF8_ENABLE) {
156+ $utf8u = 'u';
157+ } else {
158+ $utf8u = '';
159+ }
160+ }
143161 $matches = $arr = array();
144- preg_match_all('/' . $this->pattern . '/x', $string, $matches, PREG_SET_ORDER);
162+ preg_match_all('/' . $this->pattern . '/x' . $utf8u,
163+ $string, $matches, PREG_SET_ORDER);
145164 foreach ($matches as $match) {
146165 $obj = $this->get_converter($match);
147166 if ($obj->set($match, $page) !== FALSE) {
@@ -277,11 +296,20 @@ EOD;
277296
278297 function set($arr, $page)
279298 {
299+ static $utf8u; // 'u'(PCRE_UTF8) or ''
300+ if (! isset($utf8u)) {
301+ if (version_compare('7.0.0', PHP_VERSION, '<=')
302+ && PKWK_UTF8_ENABLE) {
303+ $utf8u = 'u';
304+ } else {
305+ $utf8u = '';
306+ }
307+ }
280308 list($all, $this->plain, $name, $this->param, $body) = $this->splice($arr);
281309
282310 // Re-get true plugin name and patameters (for PHP 4.1.2)
283311 $matches = array();
284- if (preg_match('/^' . $this->pattern . '/x', $all, $matches)
312+ if (preg_match('/^' . $this->pattern . '/x' . $utf8u, $all, $matches)
285313 && $matches[1] != $this->plain)
286314 list(, $this->plain, $name, $this->param) = $matches;
287315
Show on old repository browser