Changeset 600170
- Timestamp:
- 09/17/2012 05:21:19 PM (14 years ago)
- Location:
- wp-markdown-syntaxhighlighter/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
wp-markdown-syntaxhighlighter.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-markdown-syntaxhighlighter/trunk/readme.txt
r598545 r600170 5 5 Requires at least: 3.1 6 6 Tested up to: 3.4.1 7 Stable tag: 0. 3.17 Stable tag: 0.4 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 73 73 == Changelog == 74 74 75 = 0.4 = 76 77 * Switched from `preg_replace()` to `preg_replace_callback` for () 78 * Removed some potentially harmful formatting code 79 * *Hat tip to Richard Cyrus for suggesting these changes* 80 75 81 = 0.3.1 = 76 82 -
wp-markdown-syntaxhighlighter/trunk/wp-markdown-syntaxhighlighter.php
r598541 r600170 4 4 Plugin URI: http://www.mattshelton.net 5 5 Description: This WordPress plugin attempts to properly tag code blocks for SyntaxHighlighter parsing 6 Version: 0. 3.16 Version: 0.4 7 7 Author: Matt Shelton 8 8 Author URI: http://www.mattshelton.net … … 45 45 46 46 function wmsh_filter_markdown( $text ) { 47 $return = preg_replace( '|<pre><code>#!!([^\n]+)\n(.*?)</code></pre>|se', 'wmsh_add_parameters(\'$2\',\'$1\');', $text); 48 $return = preg_replace( '|<pre><code>#!([^\n]+)\n(.*?)</code></pre>|se', 'wmsh_add_language(\'$2\',\'$1\');', $return); 49 return $return; 47 $return = preg_replace_callback( 48 '|<pre><code>#!!([^\n]+)\n(.*?)</code></pre>|s', 49 function( $m ) { 50 return wmsh_add_parameters($m[2], $m[1]); 51 }, 52 $text 53 ); 54 55 $return = preg_replace_callback( 56 '|<pre><code>#!([^\n]+)\n(.*?)</code></pre>|s', 57 function( $m ) { 58 return wmsh_add_language($m[2],$m[1]); 59 }, 60 $return 61 ); 62 63 return $return; 50 64 } 51 65 … … 115 129 */ 116 130 function wmsh_add_language( $code, $language ) { 117 if(strcasecmp($language, 'xml') == 0) {118 $code = stripslashes( trim( str_replace(array('&', ''', '"'), array('&','\'','"'), $code) ) );119 } else {120 $code = stripslashes( trim( htmlspecialchars_decode( $code, ENT_NOQUOTES ) ) );121 }122 131 return '<pre class="' . WMSH_BRUSH . ': '. $language . '; notranslate">' . $code . '</pre>'; 123 132 } … … 143 152 $class = parseParameters($params) . "notranslate"; 144 153 145 if(strcasecmp($params[WMSH_BRUSH], 'xml') == 0) {146 $code = stripslashes( trim( str_replace(array('&', ''', '"'), array('&','\'','"'), $code) ) );147 } else {148 $code = stripslashes( trim( htmlspecialchars_decode( $code, ENT_NOQUOTES ) ) );149 }150 154 151 155 $output = "<pre class=\"" . $class . "\"";
Note: See TracChangeset
for help on using the changeset viewer.