<?php
// PukiWiki - Yet another WikiWikiWeb clone.
-// $Id: make_link.php,v 1.28 2005/06/27 14:18:07 henoheno Exp $
+// $Id: make_link.php,v 1.38 2011/01/25 15:01:01 henoheno Exp $
// Copyright (C)
-// 2003-2005 PukiWiki Developers Team
+// 2003-2007 PukiWiki Developers Team
// 2001-2002 Originally written by yu-ji
// License: GPL v2 or (at your option) any later version
//
$string = preg_replace_callback('/' . $this->pattern . '/x',
array(& $this, 'replace'), $string);
- $arr = explode("\x08", make_line_rules(htmlspecialchars($string)));
+ $arr = explode("\x08", make_line_rules(htmlsc($string)));
$retval = '';
while (! empty($arr)) {
$retval .= array_shift($arr) . array_shift($this->result);
$obj = $this->get_converter($arr);
$this->result[] = ($obj !== NULL && $obj->set($arr, $this->page) !== FALSE) ?
- $obj->toString() : make_line_rules(htmlspecialchars($arr[0]));
+ $obj->toString() : make_line_rules(htmlsc($arr[0]));
return "\x08"; // Add a mark into latest processed part
}
$this->type = $type;
if (! PKWK_DISABLE_INLINE_IMAGE_FROM_URI &&
is_url($alias) && preg_match('/\.(gif|png|jpe?g)$/i', $alias)) {
- $alias = '<img src="' . htmlspecialchars($alias) . '" alt="' . $name . '" />';
+ $alias = '<img src="' . htmlsc($alias) . '" alt="' . $name . '" />';
} else if ($alias != '') {
if ($converter === NULL)
$converter = new InlineConverter(array('plugin'));
} else {
// No such plugin, or Failed
$body = (($body == '') ? '' : '{' . $body . '}') . ';';
- return make_line_rules(htmlspecialchars('&' . $this->plain) . $body);
+ return make_line_rules(htmlsc('&' . $this->plain) . $body);
}
}
}
{
return <<<EOD
\(\(
- ((?:(?R)|(?!\)\)).)*) # (1) note body
+ ((?>(?=\(\()(?R)|(?!\)\)).)*) # (1) note body
\)\)
EOD;
}
list(, $body) = $this->splice($arr);
- $script = '';
- if (! PKWK_ALLOW_RELATIVE_FOOTNOTE_ANCHOR)
- $script = get_script_uri() . '?' . $page;
+ if (PKWK_ALLOW_RELATIVE_FOOTNOTE_ANCHOR) {
+ $script = '';
+ } else {
+ $script = get_script_uri() . '?' . pagename_urlencode($page);
+ }
$id = ++$note_id;
$note = make_link($body);
'<span class="small">' . $note . '</span><br />';
// A hyperlink, content-body to footnote
+ if (! is_numeric(PKWK_FOOTNOTE_TITLE_MAX) || PKWK_FOOTNOTE_TITLE_MAX <= 0) {
+ $title = '';
+ } else {
+ $title = strip_tags($note);
+ $count = mb_strlen($title, SOURCE_ENCODING);
+ $title = mb_substr($title, 0, PKWK_FOOTNOTE_TITLE_MAX, SOURCE_ENCODING);
+ $abbr = (mb_strlen($title) < $count) ? '...' : '';
+ $title = ' title="' . $title . $abbr . '"';
+ }
$name = '<a id="notetext_' . $id . '" href="' . $script .
- '#notefoot_' . $id . '" class="note_super" title="' .
- strip_tags($note) . '">*' . $id . '</a>';
+ '#notefoot_' . $id . '" class="note_super"' . $title .
+ '>*' . $id . '</a>';
return parent::setParam($page, $name, $body);
}
function set($arr, $page)
{
list(, , $alias, $name) = $this->splice($arr);
- return parent::setParam($page, htmlspecialchars($name),
+ return parent::setParam($page, htmlsc($name),
'', 'url', $alias == '' ? $name : $alias);
}
function set($arr, $page)
{
list(, $name, $alias) = $this->splice($arr);
- return parent::setParam($page, htmlspecialchars($name), '', 'url', $alias);
+ return parent::setParam($page, htmlsc($name), '', 'url', $alias);
}
function toString()
$url = get_interwiki_url($name, $this->param);
$this->url = ($url === FALSE) ?
- $script . '?' . rawurlencode('[[' . $name . ':' . $this->param . ']]') :
- htmlspecialchars($url);
+ $script . '?' . pagename_urlencode('[[' . $name . ':' . $this->param . ']]') :
+ htmlsc($url);
return parent::setParam(
$page,
- htmlspecialchars($name . ':' . $this->param),
+ htmlsc($name . ':' . $this->param),
'',
'InterWikiName',
$alias == '' ? $name . ':' . $this->param : $alias
{
global $script, $vars, $link_compact, $related, $_symbol_noexists;
- $s_page = htmlspecialchars(strip_bracket($page));
+ $s_page = htmlsc(strip_bracket($page));
$s_alias = ($alias == '') ? $s_page : $alias;
if ($page == '') return '<a href="' . $anchor . '">' . $s_alias . '</a>';
- $r_page = rawurlencode($page);
+ $r_page = pagename_urlencode($page);
$r_refer = ($refer == '') ? '' : '&refer=' . rawurlencode($refer);
- if (! isset($related[$page]) && $page != $vars['page'] && is_page($page))
+ if (! isset($related[$page]) && $page !== $vars['page'] && is_page($page))
$related[$page] = get_filetime($page);
if ($isautolink || is_page($page)) {
return $url;
}
-?>
+