Make WordPress Core

Ticket #6992: 6992.diff

File 6992.diff, 2.4 KB (added by regulatethis, 16 years ago)

PHP4 compatible fix

  • wp-includes/compat.php

     
    9696        return implode( '', $chars );
    9797}
    9898
     99function php_compat_htmlspecialchars_decode($string, $quote_style = null)
     100{
     101    // Sanity check
     102        if (!is_scalar($string)) {
     103                user_error('htmlspecialchars_decode() expects parameter 1 to be string, ' .gettype($string) . ' given', E_USER_WARNING);
     104                return;
     105        }
     106
     107        if (!is_int($quote_style) && $quote_style !== null) {
     108                user_error('htmlspecialchars_decode() expects parameter 2 to be integer, ' .gettype($quote_style) . ' given', E_USER_WARNING);
     109                return;
     110        }
     111       
     112        // Init
     113        $from   = array('&', '<', '>');
     114        $to     = array('&', '<', '>');
     115
     116        // The function does not behave as documented
     117        // This matches the actual behaviour of the function
     118        if ($quote_style & ENT_COMPAT || $quote_style & ENT_QUOTES) {
     119                $from[] = '&quot;';
     120                $to[]   = '"';
     121               
     122                $from[] = '&#039;';
     123                $to[]   = "'";
     124        }
     125        return str_replace($from, $to, $string);
     126}
     127
     128if (!function_exists('htmlspecialchars_decode')) {
     129        function htmlspecialchars_decode($string, $quote_style = null)
     130        {
     131                return php_compat_htmlspecialchars_decode($string, $quote_style);
     132        }
     133}
    99134?>
  • wp-includes/comment-template.php

     
    818818        } else if ( empty($comment_author) ) {
    819819                $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1' ORDER BY comment_date", $post->ID));
    820820        } else {
    821                 $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date", $post->ID, $comment_author, $comment_author_email));
     821                $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date", $post->ID, htmlspecialchars_decode($comment_author, ENT_QUOTES), $comment_author_email));
    822822        }
    823823
    824824        // keep $comments for legacy's sake