Skip to content

Commit

Permalink
Encode shortcode opening tags
Browse files Browse the repository at this point in the history
  • Loading branch information
yscik committed Jan 26, 2021
1 parent b6e9202 commit 84e8797
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions syntaxhighlighter.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,9 +533,6 @@ public function render_block( $attributes, $content ) {

$code = preg_replace( '#<pre [^>]+>([^<]+)?</pre>#', '$1', $content );

// Escape shortcodes
$code = preg_replace('/' . get_shortcode_regex() . '/', '[$0]', $code );

// Undo escaping done by WordPress
$code = htmlspecialchars_decode( $code );
$code = preg_replace( '/^(\s*https?:)&#0?47;&#0?47;([^\s<>"]+\s*)$/m', '$1//$2', $code );
Expand Down Expand Up @@ -1330,6 +1327,9 @@ function shortcode_callback( $atts, $code = '', $tag = false ) {

$code = ( false === strpos( $code, '<' ) && false === strpos( $code, '>' ) && 2 == $this->get_code_format($post) ) ? strip_tags( $code ) : htmlspecialchars( $code );

// Escape shortcodes
$code = preg_replace( '/\[/', '&#91;', $code );

$params[] = 'notranslate'; // For Google, see http://otto42.com/9k

$params = apply_filters( 'syntaxhighlighter_cssclasses', $params ); // Use this to add additional CSS classes / SH parameters
Expand Down

0 comments on commit 84e8797

Please sign in to comment.