Ticket #6518: shortcode-escaping-r7583.patch
File shortcode-escaping-r7583.patch, 1.3 KB (added by , 17 years ago) |
---|
-
wordpress/wp-includes/shortcodes.php
75 75 $tagnames = array_keys($shortcode_tags); 76 76 $tagregexp = join( '|', array_map('preg_quote', $tagnames) ); 77 77 78 $pattern = '/ \[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\1\])?/s';78 $pattern = '/(.?)\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)/s'; 79 79 80 80 return preg_replace_callback($pattern, 'do_shortcode_tag', $content); 81 81 } 82 82 83 83 function do_shortcode_tag($m) { 84 84 global $shortcode_tags; 85 86 // allow [[foo]] syntax for escaping a tag 87 if ($m[1] == '[' && $m[6] == ']') { 88 return substr($m[0], 1, -1); 89 } 85 90 86 $tag = $m[ 1];87 $attr = shortcode_parse_atts($m[ 2]);91 $tag = $m[2]; 92 $attr = shortcode_parse_atts($m[3]); 88 93 89 if ( isset($m[ 4]) ) {94 if ( isset($m[5]) ) { 90 95 // enclosing tag - extra parameter 91 return call_user_func($shortcode_tags[$tag], $attr, $m[4]);96 return $m[1] . call_user_func($shortcode_tags[$tag], $attr, $m[5]) . $m[6]; 92 97 } else { 93 98 // self-closing tag 94 return call_user_func($shortcode_tags[$tag], $attr);99 return $m[1] . call_user_func($shortcode_tags[$tag], $attr) . $m[6]; 95 100 } 96 101 } 97 102