forked from jjchico/publist
-
Notifications
You must be signed in to change notification settings - Fork 2
/
sanitiser.php
56 lines (52 loc) · 1.7 KB
/
sanitiser.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
* DokuWiki Plugin publist (Sanitiser Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Jorge Juan <jjchico@gmail.com>
*/
// Simple latex to utf8 sanitiser. Extend as needed.
// Rename (or copy) this file to "sanitiser.php" and it will be automatically
// used by publist.
$sanitiser = function ($inputstr) {
$search_array = array(
'\$', '\&', '\%', '\#', '\_', '\{', '\}', // specials
'{', '}', // emphasizers
"\'a", "\'e", "\'i", "\'o", "\'u", // acute
"\'A", "\'E", "\'I", "\'O", "\'U",
'\`a', '\`e', '\`i', '\`o', '\`u', // grave
'\`A', '\`E', '\`I', '\`O', '\`U',
'\^a', '\^e', '\^i', '\^o', '\^u', // circumflex
'\^A', '\^E', '\^I', '\^O', '\^U',
'\"a', '\"e', '\"i', '\"o', '\"u', // umlaut
'\"A', '\"E', '\"I', '\"O', '\"U',
'\vc', '\vs',
"\'y",
'\~n', // tilde
'\~N',
'\cc', '\cC',
'~', '\,', '\\' // space
);
$replace_array = array(
'$', '&', '%', '#', '_', '<html>{</html>', '<html>}</html>',
'','',
'á', 'é', 'í', 'ó', 'ú',
'Á', 'É', 'Í', 'Ó', 'Ú',
'à', 'è', 'ì', 'ò', 'ù',
'À', 'È', 'Ì', 'Ò', 'Ù',
'â', 'ê', 'î', 'ô', 'û',
'Â', 'Ê', 'Î', 'Ô', 'Û',
'ä', 'ë', 'ï', 'ö', 'ü',
'Ä', 'Ë', 'Ï', 'Ö', 'Ü',
'č', 'š',
'ý',
'ñ',
'Ñ',
'ç', 'Ç',
"\xC2\xA0", ' ', ' '
);
$outputstr = str_replace($search_array, $replace_array, $inputstr);
return $outputstr;
}
// vim:ts=4:sw=4:et:enc=utf-8:
?>