Fixed issue 70, markdown syntax in the Wiki partially broken.
We will need to iterate with feedback from the users for the autorized tags in the filtering process.
This commit is contained in:
parent
2732da9dbb
commit
b45d9854af
@ -36,19 +36,6 @@ class IDF_Template_Markdown extends Pluf_Template_Tag
|
||||
{
|
||||
$this->project = $request->project;
|
||||
$this->request = $request;
|
||||
$filter = new IDF_Template_MarkdownPrefilter();
|
||||
$text = $filter->go($text);
|
||||
// The filter has replace < and > also in the code blocks so
|
||||
// we need to revert them
|
||||
$tmp = array();
|
||||
foreach (preg_split("/\015\012|\015|\012/", $text, -1) as $s) {
|
||||
if (0 === strpos($s, ' ')) {
|
||||
$s = str_replace(array('<', '>'),
|
||||
array('<', '>'), $s);
|
||||
}
|
||||
$tmp[] = $s;
|
||||
}
|
||||
$text = implode("\n", $tmp);
|
||||
// Replace like in the issue text
|
||||
$tag = new IDF_Template_IssueComment();
|
||||
$text = $tag->start($text, $request, false, false, false, false);
|
||||
@ -57,7 +44,8 @@ class IDF_Template_Markdown extends Pluf_Template_Tag
|
||||
$text = preg_replace_callback('#\[\[([A-Za-z0-9\-]+)\]\]#im',
|
||||
array($this, 'callbackWikiPage'),
|
||||
$text);
|
||||
echo Pluf_Text_MarkDown_parse($text);
|
||||
$filter = new IDF_Template_MarkdownPrefilter();
|
||||
echo $filter->go(Pluf_Text_MarkDown_parse($text));
|
||||
}
|
||||
|
||||
function callbackWikiPage($m)
|
||||
|
@ -22,13 +22,10 @@
|
||||
# ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* Strict class to only allow entities.
|
||||
* Should be renamed MarkdownPostfilter.
|
||||
*/
|
||||
class IDF_Template_MarkdownPrefilter extends Pluf_Text_HTML_Filter
|
||||
{
|
||||
public $allowed = array();
|
||||
public $always_close = array();
|
||||
public $remove_blanks = array();
|
||||
public $allowed_entities = array(
|
||||
'amp',
|
||||
'gt',
|
||||
@ -91,4 +88,81 @@ class IDF_Template_MarkdownPrefilter extends Pluf_Text_HTML_Filter
|
||||
'upsih',
|
||||
'piv',
|
||||
);
|
||||
|
||||
public $allowed = array(
|
||||
'img' => array('src', 'class', 'alt', 'height', 'width'),
|
||||
'strong' => array(),
|
||||
'em' => array(),
|
||||
'b' => array(),
|
||||
'i' => array(),
|
||||
'ul' => array(),
|
||||
'ol' => array(),
|
||||
'li' => array(),
|
||||
'p' => array('align', 'class'),
|
||||
'div' => array('align', 'class'),
|
||||
'br' => array(),
|
||||
'pre' => array(),
|
||||
'table' => array('summary'),
|
||||
'caption' => array(),
|
||||
'tr' => array(),
|
||||
'td' => array('style'),
|
||||
'h1' => array(),
|
||||
'h2' => array(),
|
||||
'h3' => array(),
|
||||
'hr' => array(),
|
||||
'address' => array(),
|
||||
'a' => array('href', 'title', 'rel'),
|
||||
'blockquote' => array(),
|
||||
);
|
||||
// tags which should always be self-closing (e.g. "<img />")
|
||||
public $no_close = array(
|
||||
'img',
|
||||
'br',
|
||||
'hr',
|
||||
);
|
||||
|
||||
// tags which must always have seperate opening and closing tags
|
||||
// (e.g. "<b></b>")
|
||||
public $always_close = array(
|
||||
'strong',
|
||||
'em',
|
||||
'b',
|
||||
'i',
|
||||
'ul',
|
||||
'ol',
|
||||
'li',
|
||||
'p',
|
||||
'table',
|
||||
'caption',
|
||||
'tr',
|
||||
'td',
|
||||
'span',
|
||||
'a',
|
||||
'blockquote',
|
||||
'pre',
|
||||
'iframe',
|
||||
'h1', 'h2', 'h3', 'address'
|
||||
);
|
||||
// attributes which should be checked for valid protocols
|
||||
public $protocol_attributes = array(
|
||||
'src',
|
||||
'href',
|
||||
);
|
||||
// protocols which are allowed
|
||||
public $allowed_protocols = array(
|
||||
'http',
|
||||
'https',
|
||||
'ftp',
|
||||
'mailto',
|
||||
);
|
||||
// tags which should be removed if they contain no content
|
||||
// (e.g. "<b></b>" or "<b />")
|
||||
public $remove_blanks = array(
|
||||
'p',
|
||||
'strong',
|
||||
'em',
|
||||
'caption',
|
||||
'li',
|
||||
'span',
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user