Make WordPress Core


Ignore:
Timestamp:
08/14/2004 04:08:57 PM (22 years ago)
Author:
rboren
Message:

Use sanitize_title() to process post, page, author, and category names in the query.

File:
1 edited

Legend:

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

    r1531 r1533  
    219219
    220220        if ('' != $q['name']) {
    221             $q['name'] = preg_replace('/[^a-z0-9-_]/', '', $q['name']);
     221        $q['name'] = sanitize_title($q['name']);
    222222            $where .= " AND post_name = '" . $q['name'] . "'";
    223223        } else if ('' != $q['pagename']) {
    224224        // If pagename is set, set static to true and set name to pagename.
    225         $q['pagename'] = preg_replace('/[^a-z0-9-_]/', '', $q['pagename']);
     225        $q['pagename'] = sanitize_title($q['pagename']);
    226226        $q['name'] = $q['pagename'];
    227227        $q['static'] = true;
     
    317317                }
    318318            }
    319             $q['category_name'] = preg_replace('|[^a-z0-9-_]|i', '', $q['category_name']);
     319            $q['category_name'] = sanitize_title($q['category_name']);
    320320            $tables = ", $wpdb->post2cat, $wpdb->categories";
    321321            $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) LEFT JOIN $wpdb->categories ON ($wpdb->post2cat.category_id = $wpdb->categories.cat_ID) ";
     
    361361                }
    362362            }
    363             $q['author_name'] = preg_replace('|[^a-z0-9-_]|', '', strtolower($q['author_name']));
     363            $q['author_name'] = sanitize_title($q['author_name']);
    364364            $q['author'] = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_nicename='".$q['author_name']."'");
    365365            $whichauthor .= ' AND (post_author = '.intval($q['author']).')';
Note: See TracChangeset for help on using the changeset viewer.