コミットメタ情報

リビジョン5c886a60262eac17b2c646d6b071098ad9bffd57 (tree)
日時2015-01-20 01:44:49
作者umorigu <umorigu@gmai...>
コミッターumorigu

ログメッセージ

Remove create_function function for stability

変更サマリ

差分

--- a/lib/html.php
+++ b/lib/html.php
@@ -124,34 +124,51 @@ function catbody($title, $page, $body)
124124 arsort($keys, SORT_NUMERIC);
125125 $keys = get_search_words(array_keys($keys), TRUE);
126126 $id = 0;
127+ $patterns = '';
127128 foreach ($keys as $key=>$pattern) {
128- $s_key = htmlsc($key);
129- $pattern = '/' .
130- '<textarea[^>]*>.*?<\/textarea>' . // Ignore textareas
131- '|' . '<[^>]*>' . // Ignore tags
132- '|' . '&[^;]+;' . // Ignore entities
133- '|' . '(' . $pattern . ')' . // $matches[1]: Regex for a search word
134- '/sS';
135- $decorate_Nth_word = create_function(
136- '$matches',
137- 'return (isset($matches[1])) ? ' .
138- '\'<strong class="word' .
139- $id .
140- '">\' . $matches[1] . \'</strong>\' : ' .
141- '$matches[0];'
142- );
143- $body = preg_replace_callback($pattern, $decorate_Nth_word, $body);
144- $notes = preg_replace_callback($pattern, $decorate_Nth_word, $notes);
145- ++$id;
129+ if (strlen($patterns) > 0) {
130+ $pattern .= '|';
131+ }
132+ $patterns = '(' . $pattern . ')';
146133 }
134+ $pattern = '/' .
135+ '<textarea[^>]*>.*?<\/textarea>' . // Ignore textareas
136+ '|' . '<[^>]*>' . // Ignore tags
137+ '|' . '&[^;]+;' . // Ignore entities
138+ '|' . '(' . $patterns . ')' . // $matches[1]: Regex for a search word
139+ '/sS';
140+ $body = preg_replace_callback($pattern, '_decorate_Nth_word', $body);
141+ $notes = preg_replace_callback($pattern, '_decorate_Nth_word', $notes);
142+ $s_key = htmlsc($key);
143+ $pattern = '/' .
144+ '<textarea[^>]*>.*?<\/textarea>' . // Ignore textareas
145+ '|' . '<[^>]*>' . // Ignore tags
146+ '|' . '&[^;]+;' . // Ignore entities
147+ '|' . '(' . $pattern . ')' . // $matches[1]: Regex for a search word
148+ '/sS';
149+ $body = preg_replace_callback($pattern, '_decorate_Nth_word', $body);
150+ $notes = preg_replace_callback($pattern, '_decorate_Nth_word', $notes);
147151 }
148-
149152 // Compat: 'HTML convert time' without time about MenuBar and skin
150153 $taketime = elapsedtime();
151154
152155 require(SKIN_FILE);
153156 }
154157
158+function _decorate_Nth_word($matches)
159+{
160+ $index = 0;
161+ for ($i = 2; $i < count($matches); $i++) {
162+ if (isset($matches[$i])) {
163+ $index = $i;
164+ }
165+ }
166+ return (isset($matches[1])) ?
167+ '<strong class="word'
168+ . $index .
169+ '>' . $matches[0] . '</strong>' : $matches[0];
170+}
171+
155172 // Show 'edit' form
156173 function edit_form($page, $postdata, $digest = FALSE, $b_template = TRUE)
157174 {
@@ -164,7 +181,7 @@ function edit_form($page, $postdata, $digest = FALSE, $b_template = TRUE)
164181 if ($digest === FALSE) $digest = md5(join('', get_source($page)));
165182
166183 $refer = $template = '';
167-
184+
168185 // Add plugin
169186 $addtag = $add_top = '';
170187 if(isset($vars['add'])) {
旧リポジトリブラウザで表示