2 /* vim: set expandtab sw=4 ts=4 sts=4: */
6 * This is in a separate script because it's called from a number of scripts
10 * Sanitizes $message, taking into account our special codes
13 * @uses preg_replace()
15 * @param string the message
17 * @return string the sanitized message
21 function PMA_sanitize($message)
23 $replace_pairs = array(
26 '[i]' => '<em>', // deprecated by em
27 '[/i]' => '</em>', // deprecated by 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
37 '[/code]' => '</code>',
45 $message = strtr($message, $replace_pairs);
47 $pattern = '/\[a@([^"@]*)@([^]"]*)\]/';
49 if (preg_match_all($pattern, $message, $founds, PREG_SET_ORDER
)) {
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)) {
60 // a-z and _ allowed in target
61 if (! empty($found[2]) && preg_match('/[^a-z_]+/i', $found[2])) {
66 $message = preg_replace($pattern, '<a href="\1" target="\2">', $message);