From ba0f401390c48332e0e169fa65b966db18687db1 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 20 Aug 2007 22:50:04 +0000 Subject: [PATCH] bookmark sanitizer funcs and default filter cleanup. see #4546 git-svn-id: http://svn.automattic.com/wordpress/trunk@5906 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/bookmark.php | 37 ++---- wp-admin/link-manager.php | 11 +- wp-includes/bookmark.php | 81 ++++++++++++- wp-includes/default-filters.php | 195 ++++++++++++-------------------- wp-includes/post.php | 5 +- wp-includes/taxonomy.php | 5 +- 6 files changed, 170 insertions(+), 164 deletions(-) diff --git a/wp-admin/includes/bookmark.php b/wp-admin/includes/bookmark.php index 3bceb22419..35cc9c9d22 100644 --- a/wp-admin/includes/bookmark.php +++ b/wp-admin/includes/bookmark.php @@ -60,23 +60,17 @@ function wp_get_link_cats($link_id = 0) { } function get_link_to_edit( $link_id ) { - $link = get_link( $link_id ); - - $link->link_url = clean_url($link->link_url); - $link->link_name = attribute_escape($link->link_name); - $link->link_image = attribute_escape($link->link_image); - $link->link_description = attribute_escape($link->link_description); - $link->link_rss = clean_url($link->link_rss); - $link->link_rel = attribute_escape($link->link_rel); - $link->link_notes = wp_specialchars($link->link_notes); - $link->post_category = $link->link_category; - - return $link; + return get_link( $link_id, OBJECT, 'edit' ); } function wp_insert_link($linkdata) { global $wpdb, $current_user; + $defaults = array('link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0 ); + + $linkdata = wp_parse_args($linkdata, $defaults); + $linkdata = sanitize_bookmark($linkdata, 'db'); + extract($linkdata, EXTR_SKIP); $update = false; @@ -84,53 +78,38 @@ function wp_insert_link($linkdata) { if ( !empty($link_id) ) $update = true; - $link_id = (int) $link_id; - - if( trim( $link_name ) == '' ) + if ( trim( $link_name ) == '' ) return 0; - $link_name = apply_filters('pre_link_name', $link_name); - if( trim( $link_url ) == '' ) + if ( trim( $link_url ) == '' ) return 0; - $link_url = apply_filters('pre_link_url', $link_url); if ( empty($link_rating) ) $link_rating = 0; - else - $link_rating = (int) $link_rating; if ( empty($link_image) ) $link_image = ''; - $link_image = apply_filters('pre_link_image', $link_image); if ( empty($link_target) ) $link_target = ''; - $link_target = apply_filters('pre_link_target', $link_target); if ( empty($link_visible) ) $link_visible = 'Y'; - $link_visibile = preg_replace('/[^YNyn]/', '', $link_visible); if ( empty($link_owner) ) $link_owner = $current_user->id; - else - $link_owner = (int) $link_owner; if ( empty($link_notes) ) $link_notes = ''; - $link_notes = apply_filters('pre_link_notes', $link_notes); if ( empty($link_description) ) $link_description = ''; - $link_description = apply_filters('pre_link_description', $link_description); if ( empty($link_rss) ) $link_rss = ''; - $link_rss = apply_filters('pre_link_rss', $link_rss); if ( empty($link_rel) ) $link_rel = ''; - $link_rel = apply_filters('pre_link_rel', $link_rel); // Make sure we set a valid category if (0 == count($link_category) || !is_array($link_category)) { diff --git a/wp-admin/link-manager.php b/wp-admin/link-manager.php index 8141af0f08..0033835cf5 100644 --- a/wp-admin/link-manager.php +++ b/wp-admin/link-manager.php @@ -80,7 +80,7 @@ $categories = get_terms('link_category', "hide_empty=1"); $select_cat = "\n"; $select_order = "