2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * This is in a separate script because it's called from a number of scripts
11 * Sanitizes $message, taking into account our special codes
14 * @uses preg_replace()
16 * @param string the message
18 * @return string the sanitized message
22 function PMA_sanitize($message)
24 $replace_pairs = array(
27 '[i]' => '<em>', // deprecated by em
28 '[/i]' => '</em>', // deprecated by em
31 '[b]' => '<strong>', // deprecated by strong
32 '[/b]' => '</strong>', // deprecated by strong
33 '[strong]' => '<strong>',
34 '[/strong]' => '</strong>',
35 '[tt]' => '<code>', // deprecated by CODE or KBD
36 '[/tt]' => '</code>', // deprecated by CODE or KBD
38 '[/code]' => '</code>',
46 $message = strtr($message, $replace_pairs);
48 $pattern = '/\[a@([^"@]*)@([^]"]*)\]/';
50 if (preg_match_all($pattern, $message, $founds, PREG_SET_ORDER
)) {
52 'http', // default http:// links (and https://)
53 './Do', // ./Documentation
56 foreach ($founds as $found) {
57 // only http... and ./Do... allowed
58 if (! in_array(substr($found[1], 0, 4), $valid_links)) {
61 // a-z and _ allowed in target
62 if (! empty($found[2]) && preg_match('/[^a-z_]+/i', $found[2])) {
67 $message = preg_replace($pattern, '<a href="\1" target="\2">', $message);