Make WordPress Core


Ignore:
Timestamp:
10/28/2010 07:38:00 AM (13 years ago)
Author:
westi
Message:

Purger more create_function usage during autop and iso descrambling. See #14424 props ScottMac.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/formatting.php

    r15948 r16035  
    209209    $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee);
    210210    if ($br) {
    211         $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', create_function('$matches', 'return str_replace("\n", "<WPPreserveNewline />", $matches[0]);'), $pee);
     211        $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '__autop_newline_preservation_helper', $pee);
    212212        $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks
    213213        $pee = str_replace('<WPPreserveNewline />', "\n", $pee);
     
    220220
    221221    return $pee;
     222}
     223
     224/**
     225 * Newline preservation help function for wpautop
     226 *
     227 * @since 3.1.0
     228 * @access private
     229 * @param array $matches preg_replace_callback matches array
     230 * @returns string
     231 */
     232function __autop_newline_preservation_helper( $matches ) {
     233    return str_replace("\n", "<WPPreserveNewline />", $matches[0]);
    222234}
    223235
     
    15561568    } else {
    15571569        $subject = str_replace('_', ' ', $matches[2]);
    1558         $subject = preg_replace_callback('#\=([0-9a-f]{2})#i', create_function('$match', 'return chr(hexdec(strtolower($match[1])));'), $subject);
     1570        $subject = preg_replace_callback('#\=([0-9a-f]{2})#i', '__wp_iso_convert', $subject);
    15591571        return $subject;
    15601572    }
    15611573}
     1574
     1575/**
     1576 * Helper function to convert hex encoded chars to ascii
     1577 *
     1578 * @since 3.1.0
     1579 * @access private
     1580 * @param $match the preg_replace_callback matches array
     1581 */
     1582function __wp_iso_convert( $match ) {
     1583    return chr( hexdec( strtolower( $match[1] ) ) );
     1584}
    15621585
    15631586/**
Note: See TracChangeset for help on using the changeset viewer.