インラインプラグインの{body}は、適宜WikiName, BracketName, 特に AutoLinkを回避しなければならない †
修正 †
関連 †
メッセージ †&inline(arguments,argument2, ... ,argumentN){body text message}; 現在のWikiName, BracketName, AutoLinkの仕様では、{body}部分を利用するインラインプラグインについて、{body}に対して事前にstrip_htmltag()をかけておかなければ、挿入されたリンク文字列(アンカータグ)による影響を受けてしまう。{body}の中の文字列は(特にAutoLinkによって偶発的に)アンカータグを挿入される可能性があり、必要に応じてそれによる影響を回避するコードを挿入しなければならない。この回避策がいままでプラグインの中にまちまちな方法で含まれていたり、物によっては含まれていなかった。
WikiNameの処理について †
修正案 †--- lib/html.php Sun Jul 03 23:51:18 2005 +++ lib/html.php Wed Aug 03 15:56:18 2005 @@ -329,7 +329,7 @@ // Remove AutoLink marker with AutLink itself function strip_autolink($str) { - return preg_replace('#<!--autolink--><a [^>]+>|</a><!--/autolink-->#', '', $str); + return preg_replace('#(?:<!--autolink-->)?<a [^>]+>|</a>(?:<!--/autolink-->)?#', '', $str); } // Make a backlink. searching-link of the page name, by the page name, for the page name --- plugin/color.inc.php Fri Jun 17 00:04:08 2005 +++ plugin/color.inc.php Wed Aug 03 16:25:08 2005 @@ -17,7 +17,7 @@ global $pkwk_dtd; $args = func_get_args(); - $text = strip_autolink(array_pop($args)); // Already htmlspecialchars(text) + $text = array_pop($args); // Already htmlspecialchars(text) list($color, $bgcolor) = array_pad($args, 2, ''); if ($color != '' && $bgcolor != '' && $text == '') { --- plugin/new.inc.php Sat Jul 16 20:01:20 2005 +++ plugin/new.inc.php Wed Aug 03 16:42:54 2005 @@ -28,17 +28,17 @@ $retval = ''; $args = func_get_args(); - $date = strip_autolink(array_pop($args)); // {date} always exists + $date = array_pop($args); // {date} always exists if($date !== '') { // Show 'New!' message by the time of the $date string if (func_num_args() > 2) return '&new([nodate]){date};'; - $timestamp = strtotime($date); + $timestamp = strtotime(strip_tags($date)); if ($timestamp === -1) return '&new([nodate]){date}: Invalid date string;'; $timestamp -= ZONETIME; - $retval = in_array('nodate', $args) ? '' : htmlspecialchars($date); + $retval = in_array('nodate', $args) ? '' : $date; } else { // Show 'New!' message by the timestamp of the page if (func_num_args() > 3) return '&new(pagename[,nolink]);';
コメント †
|