WordPress.org

Make WordPress Core

Changeset 11098


Ignore:
Timestamp:
04/27/2009 04:17:24 PM (9 years ago)
Author:
ryan
Message:

Eliminate preg_replace with /e. Props tbaboon. fixes #8689

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-phpmailer.php

    r10459 r11098  
    14041404
    14051405  /**
     1406   * Callback for converting to "=XX".
     1407   * @access private
     1408   * @return string
     1409   */
     1410  function EncodeQ_callback ($matches) {
     1411    return "=".sprintf("%02X", ord($matches[1]));
     1412  }
     1413
     1414  /**
    14061415   * Encode string to q encoding.
    14071416   * @access private
     
    14141423    switch (strtolower($position)) {
    14151424      case 'phrase':
    1416         $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
     1425        $encoded = preg_replace_callback("/([^A-Za-z0-9!*+\/ -])/",
     1426                                         "EncodeQ_callback", $encoded);
    14171427        break;
    14181428      case 'comment':
    1419         $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
     1429        $encoded = preg_replace_callback("/([\(\)\"])/",
     1430                                         "EncodeQ_callback", $encoded);
     1431        break;
    14201432      case 'text':
    14211433      default:
    14221434        /* Replace every high ascii, control =, ? and _ characters */
    1423         $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
    1424               "'='.sprintf('%02X', ord('\\1'))", $encoded);
     1435        $encoded = preg_replace_callback('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/',
     1436                                         "EncodeQ_callback", $encoded);
    14251437        break;
    14261438    }
  • trunk/wp-includes/formatting.php

    r11070 r11098  
    774774
    775775/**
     776 * Callback used to change %uXXXX to &#YYY; syntax
     777 *
     778 * @since 2.8?
     779 *
     780 * @param array $matches Single Match
     781 * @return string An HTML entity
     782 */
     783function funky_javascript_callback($matches) {
     784    return "&#".base_convert($matches[1],16,10).";";
     785}
     786
     787/**
    776788 * Fixes javascript bugs in browsers.
    777789 *
     
    789801    global $is_macIE, $is_winIE;
    790802
    791     /** @todo use preg_replace_callback() instead */
    792803    if ( $is_winIE || $is_macIE )
    793         $text =  preg_replace("/\%u([0-9A-F]{4,4})/e",  "'&#'.base_convert('\\1',16,10).';'", $text);
     804        $text =  preg_replace_callback("/\%u([0-9A-F]{4,4})/",
     805                           "funky_javascript_callback",
     806                           $text);
    794807
    795808    return $text;
Note: See TracChangeset for help on using the changeset viewer.