2 /* vim: set expandtab sw=4 ts=4 sts=4: */
9 * Sanitizes $message, taking into account our special codes
12 * @uses preg_replace()
14 * @param string the message
16 * @return string the sanitized message
20 function PMA_sanitize($message)
22 $replace_pairs = array(
25 '[i]' => '<em>', // deprecated by em
26 '[/i]' => '</em>', // deprecated by em
29 '[b]' => '<strong>', // deprecated by strong
30 '[/b]' => '</strong>', // deprecated by strong
31 '[strong]' => '<strong>',
32 '[/strong]' => '</strong>',
33 '[tt]' => '<code>', // deprecated by CODE or KBD
34 '[/tt]' => '</code>', // deprecated by CODE or KBD
36 '[/code]' => '</code>',
44 $message = strtr($message, $replace_pairs);
46 $pattern = '/\[a@([^"@]*)@([^]"]*)\]/';
48 if (preg_match_all($pattern, $message, $founds, PREG_SET_ORDER
)) {
50 'http', // default http:// links (and https://)
51 './Do', // ./Documentation
54 foreach ($founds as $found) {
55 // only http... and ./Do... allowed
56 if (! in_array(substr($found[1], 0, 4), $valid_links)) {
59 // a-z and _ allowed in target
60 if (! empty($found[2]) && preg_match('/[^a-z_]+/i', $found[2])) {
65 $message = preg_replace($pattern, '<a href="\1" target="\2">', $message);