Make WordPress Core

Changeset 14239 for trunk/wp-includes


Ignore:
Timestamp:
04/26/2010 02:10:12 PM (15 years ago)
Author:
ryan
Message:

Fix array handling in sanitize_bookmark_field(). Props mdawaffe. fixes #13098

File:
1 edited

Legend:

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

    r14131 r14239  
    310310 */
    311311function sanitize_bookmark_field($field, $value, $bookmark_id, $context) {
    312     $int_fields = array('link_id', 'link_rating');
    313     if ( in_array($field, $int_fields) )
     312    switch ( $field ) {
     313    case 'link_id' : // ints
     314    case 'link_rating' :
    314315        $value = (int) $value;
    315 
    316     // Fields which contain arrays of ints.
    317     $array_int_fields = array( 'link_category' );
    318     if ( in_array($field, $array_int_fields) ) {
    319         $value = array_map( 'absint', $value);
     316        break;
     317    case 'link_category' : // array( ints )
     318        $value = array_map('absint', (array) $value);
     319        // We return here so that the categories aren't filtered.
     320        // The 'link_category' filter is for the name of a link category, not an array of a link's link categories
    320321        return $value;
    321     }
    322 
    323     $yesno = array('link_visible');
    324     if ( in_array($field, $yesno) )
     322        break;
     323    case 'link_visible' : // bool stored as Y|N
    325324        $value = preg_replace('/[^YNyn]/', '', $value);
    326 
    327     if ( 'link_target' == $field ) {
     325        break;
     326    case 'link_target' : // "enum"
    328327        $targets = array('_top', '_blank');
    329328        if ( ! in_array($value, $targets) )
    330329            $value = '';
     330        break;
    331331    }
    332332
     
    348348        // Use display filters by default.
    349349        $value = apply_filters($field, $value, $bookmark_id, $context);
    350     }
    351 
    352     if ( 'attribute' == $context )
    353         $value = esc_attr($value);
    354     else if ( 'js' == $context )
    355         $value = esc_js($value);
     350
     351        if ( 'attribute' == $context )
     352            $value = esc_attr($value);
     353        else if ( 'js' == $context )
     354            $value = esc_js($value);
     355    }
    356356
    357357    return $value;
Note: See TracChangeset for help on using the changeset viewer.