Make WordPress Core

Changeset 11435


Ignore:
Timestamp:
05/22/2009 09:31:42 PM (16 years ago)
Author:
westi
Message:

Rename new function to sanitize_html_class() to hilight exactly what it is for, Fixes #8446.

Location:
trunk/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/comment-template.php

    r11433 r11435  
    295295        // For all registered users, 'byuser'
    296296        $classes[] = 'byuser';
    297         $classes[] = 'comment-author-' . sanitise_css_classname($user->user_nicename, $comment->user_id);
     297        $classes[] = 'comment-author-' . sanitize_html_class($user->user_nicename, $comment->user_id);
    298298        // For comment authors who are the author of the post
    299299        if ( $post = get_post($post_id) ) {
  • trunk/wp-includes/formatting.php

    r11433 r11435  
    720720
    721721/**
    722  * Santises a css classname to ensure it only contains valid characters
     722 * Santizes a html classname to ensure it only contains valid characters
    723723 *
    724  * Strips the classname down to A-Z,a-z,0-9,'-' if this results in an empty
     724 * Strips the string down to A-Z,a-z,0-9,'-' if this results in an empty
    725725 * string then it will return the alternative value supplied.
     726 *
     727 * @todo Expand to support the full range of CDATA that a class attribute can contain.
    726728 * 
    727  * @param string $classname The classname to be sanitised
    728  * @param string $alternative The value to return if the sanitisation end's up as an empty string.
    729  * @return string The sanitised value
    730  */
    731 function sanitise_css_classname($classname, $alternative){
     729 * @since 2.8.0
     730 * 
     731 * @param string $class The classname to be sanitized
     732 * @param string $fallback The value to return if the sanitization end's up as an empty string.
     733 * @return string The sanitized value
     734 */
     735function sanitize_html_class($class, $fallback){
    732736    //Strip out any % encoded octets
    733     $sanitised = preg_replace('|%[a-fA-F0-9][a-fA-F0-9]|', '', $classname);
     737    $sanitized = preg_replace('|%[a-fA-F0-9][a-fA-F0-9]|', '', $class);
    734738   
    735739    //Limit to A-Z,a-z,0-9,'-'
    736     $sanitised = preg_replace('/[^A-Za-z0-9-]/', '', $sanitised);
     740    $sanitized = preg_replace('/[^A-Za-z0-9-]/', '', $sanitized);
    737741   
    738     if ('' == $sanitised)
    739         $sanitised = $alternative;
     742    if ('' == $sanitized)
     743        $sanitized = $fallback;
    740744   
    741     return apply_filters('sanitise_css_classname',$sanitised, $classname, $alternative);   
     745    return apply_filters('sanitize_html_class',$sanitized, $class, $fallback); 
    742746}
    743747
  • trunk/wp-includes/post-template.php

    r11433 r11435  
    327327        if ( empty($cat->slug ) )
    328328            continue;
    329         $classes[] = 'category-' . sanitise_css_classname($cat->slug, $cat->cat_ID);
     329        $classes[] = 'category-' . sanitize_html_class($cat->slug, $cat->cat_ID);
    330330    }
    331331
     
    334334        if ( empty($tag->slug ) )
    335335            continue;
    336         $classes[] = 'tag-' . sanitise_css_classname($tag->slug, $tag->term_id);
     336        $classes[] = 'tag-' . sanitize_html_class($tag->slug, $tag->term_id);
    337337    }
    338338
     
    408408            $author = $wp_query->get_queried_object();
    409409            $classes[] = 'author';
    410             $classes[] = 'author-' . sanitise_css_classname($author->user_nicename , $author->user_id);
     410            $classes[] = 'author-' . sanitize_html_class($author->user_nicename , $author->user_id);
    411411        } elseif ( is_category() ) {
    412412            $cat = $wp_query->get_queried_object();
    413413            $classes[] = 'category';
    414             $classes[] = 'category-' . sanitise_css_classname($cat->slug, $cat->cat_ID);
     414            $classes[] = 'category-' . sanitize_html_class($cat->slug, $cat->cat_ID);
    415415        } elseif ( is_tag() ) {
    416416            $tags = $wp_query->get_queried_object();
    417417            $classes[] = 'tag';
    418             $classes[] = 'tag-' . sanitise_css_classname($tags->slug, $tags->term_id);
     418            $classes[] = 'tag-' . sanitize_html_class($tags->slug, $tags->term_id);
    419419        }
    420420    } elseif ( is_page() ) {
Note: See TracChangeset for help on using the changeset viewer.