Make WordPress Core

Ticket #15434: wordpress_#15434.patch

File wordpress_#15434.patch, 1.5 KB (added by rbachlec, 14 years ago)

Patch for escaping quotes and apostrophes in shortcode attribute values.

  • shortcodes.php

     
    224224 */
    225225function shortcode_parse_atts($text) {
    226226        $atts = array();
    227         $pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/';
     227        $pattern = '/(\w+)\s*=\s*"(([^"]|\\\\")*[^\\\]{1})"(?:\s|$)|(\w+)\s*=\s*\'(([^\']|\\\')*[^\\\]{1})\'(?:\s|$)|(\w+)\s*=\s*([^\s]+)(?:\s|$)|"(([^"]|\\\\")*[^\\\]{1})"(?:\s|$)|(\S+)(?:\s|$)/';
    228228        $text = preg_replace("/[\x{00a0}\x{200b}]+/u", " ", $text);
    229229        if ( preg_match_all($pattern, $text, $match, PREG_SET_ORDER) ) {
    230230                foreach ($match as $m) {
    231231                        if (!empty($m[1]))
    232232                                $atts[strtolower($m[1])] = stripcslashes($m[2]);
    233                         elseif (!empty($m[3]))
    234                                 $atts[strtolower($m[3])] = stripcslashes($m[4]);
    235                         elseif (!empty($m[5]))
    236                                 $atts[strtolower($m[5])] = stripcslashes($m[6]);
    237                         elseif (isset($m[7]) and strlen($m[7]))
    238                                 $atts[] = stripcslashes($m[7]);
    239                         elseif (isset($m[8]))
    240                                 $atts[] = stripcslashes($m[8]);
     233                        elseif (!empty($m[4]))
     234                                $atts[strtolower($m[4])] = stripcslashes($m[5]);
     235                        elseif (!empty($m[7]))
     236                                $atts[strtolower($m[7])] = stripcslashes($m[8]);
     237                        elseif (isset($m[9]) and strlen($m[9]))
     238                                $atts[] = stripcslashes($m[9]);
     239                        elseif (isset($m[11]))
     240                                $atts[] = stripcslashes($m[11]);
    241241                }
    242242        } else {
    243243                $atts = ltrim($text);