インラインプラグインの{body}は、適宜WikiName, BracketName, 特に AutoLinkを回避しなければならない

修正

  1. AutoLinkが生成するアンカー(A)タグの周囲にマーカー(コメント文)を挿入
    <!--autolink--><a href="link-to-the-page">page</a><!--/autolink-->
  2. functoin strip_autolink() を追加。マーカーの内側にあるアンカータグを、マーカーもろとも削除する
  3. 必要に応じて(strip_htmltag()の代わりに)上記関数を使用する

関連

メッセージ

  &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]);';


コメント



トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2009-03-31 (火) 17:44:38
Site admin: PukiWiki Development Team

PukiWiki 1.5.4+ © 2001-2022 PukiWiki Development Team. Powered by PHP 8.2.12. HTML convert time: 0.239 sec.

SourceForge