WordPress.org

Make WordPress Core

Ticket #16059: 16059.patch

File 16059.patch, 1.8 KB (added by hakre, 5 years ago)
  • wp-includes/kses.php

     
    551551 * @return string Content with fixed HTML tags 
    552552 */ 
    553553function wp_kses_split($string, $allowed_html, $allowed_protocols) { 
    554         global $pass_allowed_html, $pass_allowed_protocols; 
    555         $pass_allowed_html = $allowed_html; 
    556         $pass_allowed_protocols = $allowed_protocols; 
    557         return preg_replace_callback( '%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%', '_wp_kses_split_callback', $string ); 
     554        $GLOBALS['pass_allowed'] = array( $allowed_html, $allowed_protocols ); 
     555        return preg_replace_callback( '%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%', 'wp_kses_split2', $string ); 
    558556} 
    559557 
    560558/** 
    561  * Callback for wp_kses_split. 
    562  * 
    563  * @since 3.1.0 
    564  * @access private 
    565  */ 
    566 function _wp_kses_split_callback( $match ) { 
    567         global $pass_allowed_html, $pass_allowed_protocols; 
    568         return wp_kses_split2( $match[1], $pass_allowed_html, $pass_allowed_protocols ); 
    569 } 
    570  
    571 /** 
    572559 * Callback for wp_kses_split for fixing malformed HTML tags. 
    573560 * 
    574561 * This function does a lot of work. It rejects some very malformed things like 
     
    584571 * @since 1.0.0 
    585572 * @uses wp_kses_attr() 
    586573 * 
    587  * @param string $string Content to filter 
    588  * @param array $allowed_html Allowed HTML elements 
    589  * @param array $allowed_protocols Allowed protocols to keep 
     574 * @param array $match 
    590575 * @return string Fixed HTML element 
    591576 */ 
    592 function wp_kses_split2($string, $allowed_html, $allowed_protocols) { 
    593         $string = wp_kses_stripslashes($string); 
     577function wp_kses_split2( $match ) { 
     578        list( $allowed_html, $allowed_protocols ) = $GLOBALS['pass_allowed']; 
     579        $string = wp_kses_stripslashes( $match[1] ); 
    594580 
    595581        if (substr($string, 0, 1) != '<') 
    596582                return '&gt;';