Make WordPress Core

Ticket #26649: 26649-fixed.patch

File 26649-fixed.patch, 973 bytes (added by sachinrajcp123, 3 months ago)
  • src/wp-includes/shortcodes.php

    diff --git a/src/wp-includes/shortcodes.php b/src/wp-includes/shortcodes.php
    index 4f2a1e7..7b3b21a 100644
    a b function strip_shortcode_tag( $m ) { 
    193193        // allow [[foo]] syntax for escaping a tag
    194         if ( $m[1] == '[' && $m[6] == ']' ) {
    195                 return substr( $m[0], 1, -1 );
    196         }
    197         return $m[1] . $m[6];
     194        if ( $m[1] == '[' && $m[6] == ']' ) {
     195                // Return HTML entity for the left square bracket to prevent unwanted shortcode expansion.
     196                return '[' . substr( $m[0], 2, -1 );
     197        }
     198
     199        // Default behavior: return first and last matched characters.
     200        return $m[1] . $m[6];
    198201}
    199202
    200203/**
    201204 * Search content for shortcodes and filter shortcodes through their hooks.
    202205 *
    203206 * If there are no shortcode tags defined, then the content will be returned
    204207 * without any filtering. This might cause issues when using the 'get_the_excerpt'
    205208 * filter, so ensure shortcodes are correctly escaped.