This is not a know pseudoclass.
[phpmyadmin/crack.git] / libraries / sanitizing.lib.php
blob858ce487a1b109e2985668ff85c929e898ab995f
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 * This is in a separate script because it's called from a number of scripts
7 */
9 /**
10 * Sanitizes $message, taking into account our special codes
11 * for formatting
13 * @uses preg_replace()
14 * @uses strtr()
15 * @param string the message
17 * @return string the sanitized message
19 * @access public
21 function PMA_sanitize($message)
23 $replace_pairs = array(
24 '<' => '&lt;',
25 '>' => '&gt;',
26 '[i]' => '<em>', // deprecated by em
27 '[/i]' => '</em>', // deprecated by em
28 '[em]' => '<em>',
29 '[/em]' => '</em>',
30 '[b]' => '<strong>', // deprecated by strong
31 '[/b]' => '</strong>', // deprecated by strong
32 '[strong]' => '<strong>',
33 '[/strong]' => '</strong>',
34 '[tt]' => '<code>', // deprecated by CODE or KBD
35 '[/tt]' => '</code>', // deprecated by CODE or KBD
36 '[code]' => '<code>',
37 '[/code]' => '</code>',
38 '[kbd]' => '<kbd>',
39 '[/kbd]' => '</kbd>',
40 '[br]' => '<br />',
41 '[/a]' => '</a>',
42 '[sup]' => '<sup>',
43 '[/sup]' => '</sup>',
45 $message = strtr($message, $replace_pairs);
47 $pattern = '/\[a@([^"@]*)@([^]"]*)\]/';
49 if (preg_match_all($pattern, $message, $founds, PREG_SET_ORDER)) {
50 $valid_links = array(
51 'http', // default http:// links (and https://)
52 './Do', // ./Documentation
55 foreach ($founds as $found) {
56 // only http... and ./Do... allowed
57 if (! in_array(substr($found[1], 0, 4), $valid_links)) {
58 return $message;
60 // a-z and _ allowed in target
61 if (! empty($found[2]) && preg_match('/[^a-z_]+/i', $found[2])) {
62 return $message;
66 $message = preg_replace($pattern, '<a href="\1" target="\2">', $message);
69 return $message;