Ticket #9591: 9591.3.diff
File 9591.3.diff, 4.7 KB (added by , 13 years ago) |
---|
-
wp-includes/taxonomy.php
534 534 case 'slug': 535 535 case 'name': 536 536 foreach ( $terms as $i => $term ) { 537 $terms[$i] = sanitize_t erm_field('slug', $term, 0, $taxonomy, 'db');537 $terms[$i] = sanitize_title_for_query( $term ); 538 538 } 539 539 $terms = array_filter($terms); 540 540 -
wp-includes/query.php
1465 1465 ); 1466 1466 1467 1467 if ( $t->rewrite['hierarchical'] ) { 1468 $q[$t->query_var] = basename($q[$t->query_var]);1468 $q[$t->query_var] = $this->_qv_basename($q[$t->query_var]); 1469 1469 } 1470 1470 1471 1471 $term = str_replace( ' ', '+', $q[$t->query_var] ); … … 1784 1784 } 1785 1785 1786 1786 if ( '' != $q['name'] ) { 1787 $q['name'] = sanitize_title ($q['name']);1787 $q['name'] = sanitize_title_for_query( $q['name'] ); 1788 1788 $where .= " AND $wpdb->posts.post_name = '" . $q['name'] . "'"; 1789 1789 } elseif ( '' != $q['pagename'] ) { 1790 1790 if ( isset($this->queried_object_id) ) { … … 1812 1812 1813 1813 $page_for_posts = get_option('page_for_posts'); 1814 1814 if ( ('page' != get_option('show_on_front') ) || empty($page_for_posts) || ( $reqpage != $page_for_posts ) ) { 1815 $q['pagename'] = str_replace('%2F', '/', urlencode(urldecode($q['pagename']))); 1816 $page_paths = '/' . trim($q['pagename'], '/'); 1817 $q['pagename'] = sanitize_title(basename($page_paths)); 1815 $q['pagename'] = sanitize_title_for_query( $this->_qv_basename( $q['pagename'] ) ); 1818 1816 $q['name'] = $q['pagename']; 1819 1817 $where .= " AND ($wpdb->posts.ID = '$reqpage')"; 1820 1818 $reqpage_obj = get_page($reqpage); … … 1826 1824 } 1827 1825 } 1828 1826 } elseif ( '' != $q['attachment'] ) { 1829 $q['attachment'] = str_replace('%2F', '/', urlencode(urldecode($q['attachment']))); 1830 $attach_paths = '/' . trim($q['attachment'], '/'); 1831 $q['attachment'] = sanitize_title(basename($attach_paths)); 1827 $q['attachment'] = sanitize_title_for_query( $this->_qv_basename( $q['attachment'] ) ); 1832 1828 $q['name'] = $q['attachment']; 1833 1829 $where .= " AND $wpdb->posts.post_name = '" . $q['attachment'] . "'"; 1834 1830 } … … 1961 1957 $q['author_name'] = $q['author_name'][count($q['author_name'])-2]; // there was a trailling slash 1962 1958 } 1963 1959 } 1964 $q['author_name'] = sanitize_title ($q['author_name']);1960 $q['author_name'] = sanitize_title_for_query( $q['author_name'] ); 1965 1961 $q['author'] = get_user_by('slug', $q['author_name']); 1966 1962 if ( $q['author'] ) 1967 1963 $q['author'] = $q['author']->ID; … … 3134 3130 function is_404() { 3135 3131 return (bool) $this->is_404; 3136 3132 } 3133 3134 /** 3135 * i18n friendly way to get the last segment in a path 3136 * 3137 * @since 3.1.0 3138 * @access private 3139 * 3140 * @param string $path The path 3141 * @return string 3142 */ 3143 function _qv_basename( $path ) { 3144 return basename( str_replace( '%2F', '/', urlencode( urldecode( $path ) ) ) ); 3145 } 3137 3146 } 3138 3147 3139 3148 /** -
wp-includes/formatting.php
628 628 chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z', 629 629 chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z', 630 630 chr(197).chr(190) => 'z', chr(197).chr(191) => 's', 631 chr(200).chr(153) => 's', chr(200).chr(155) => 't', 631 632 // Euro Sign 632 633 chr(226).chr(130).chr(172) => 'E', 633 634 // GBP (Pound) Sign … … 783 784 * 784 785 * @param string $title The string to be sanitized. 785 786 * @param string $fallback_title Optional. A title to use if $title is empty. 787 * @param string $context Optional. The operation for which the string is sanitized 786 788 * @return string The sanitized string. 787 789 */ 788 function sanitize_title($title, $fallback_title = '' ) {790 function sanitize_title($title, $fallback_title = '', $context = 'save') { 789 791 $raw_title = $title; 790 $title = strip_tags($title);791 $title = apply_filters('sanitize_title', $title, $raw_title);792 792 793 if ( 'save' == $context ) 794 $title = remove_accents($title); 795 796 $title = apply_filters('sanitize_title', $title, $raw_title, $context); 797 793 798 if ( '' === $title || false === $title ) 794 799 $title = $fallback_title; 795 800 796 801 return $title; 797 802 } 798 803 804 function sanitize_title_for_query($title) { 805 return sanitize_title($title, '', 'query'); 806 } 807 799 808 /** 800 809 * Sanitizes title, replacing whitespace with dashes. 801 810 * … … 816 825 // Restore octets. 817 826 $title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title); 818 827 819 $title = remove_accents($title);820 828 if (seems_utf8($title)) { 821 829 if (function_exists('mb_strtolower')) { 822 830 $title = mb_strtolower($title, 'UTF-8');