Indefero

Indefero Commit Details


Date:2008-11-30 04:33:46 (16 years 22 days ago)
Author:Loic d'Anterroches
Branch:dev, develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, master, release-1.1, release-1.2, release-1.3
Commit:b45d9854aff0689700980329981ffeb2c3b5aa71
Parents: 2732da9dbb8f767cd423be1ef396f2ba20012d1c
Message: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.
Changes:

File differences

src/IDF/Template/Markdown.php
3636
3737
3838
39
40
41
42
43
44
45
46
47
48
49
50
51
5239
5340
5441
......
5744
5845
5946
60
47
48
6149
6250
6351
{
$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('&lt;', '&gt;'),
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);
$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)
src/IDF/Template/MarkdownPrefilter.php
11
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2323
24
25
26
24
25
26
2727
2828
29
30
31
3229
3330
3431
......
9188
9289
9390
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
94168
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2008 Céondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2008 Céondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** 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',
'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',
);
}

Archive Download the corresponding diff file

Page rendered in 0.08422s using 14 queries.