WordPress.org

Make WordPress Core

Changeset 12503


Ignore:
Timestamp:
12/23/09 09:52:48 (4 years ago)
Author:
westi
Message:

Improve sanitize_text_field() some more so that we don't leave extra whitespace after stripping octets. Fixes #11573.

File:
1 edited

Legend:

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

    r12499 r12503  
    28352835    if ( strpos($filtered, '<') !== false ) { 
    28362836        $filtered = wp_pre_kses_less_than( $filtered ); 
     2837        // This will strip extra whitespace for us. 
    28372838        $filtered = wp_strip_all_tags( $filtered, true ); 
    28382839    } else { 
    2839          $filtered = trim( preg_replace('/[\r\n\t ]+/', ' ', $filtered) ); 
     2840        $filtered = trim( preg_replace('/[\r\n\t ]+/', ' ', $filtered) ); 
    28402841    } 
    28412842 
    28422843    $match = array(); 
    2843     while ( preg_match('/%[a-f0-9]{2}/i', $filtered, $match) ) 
     2844    while ( preg_match('/%[a-f0-9]{2}/i', $filtered, $match) ) { 
    28442845        $filtered = str_replace($match[0], '', $filtered); 
     2846    } 
     2847    // Strip out the whitespace that may now exist after removing the octets. 
     2848    $filtered = trim( preg_replace('/[\r\n\t ]+/', ' ', $filtered) ); 
    28452849 
    28462850    return apply_filters('sanitize_text_field', $filtered, $str); 
Note: See TracChangeset for help on using the changeset viewer.