Ticket #15086: 15086.002.diff
| File 15086.002.diff, 9.2 KB (added by , 16 years ago) |
|---|
-
wp-includes/class-simplepie.php
9105 9105 return $iri->get_iri(); 9106 9106 } 9107 9107 9108 function remove_dot_segments($input)9109 {9110 $output = '';9111 while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..')9112 {9113 // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise,9114 if (strpos($input, '../') === 0)9115 {9116 $input = substr($input, 3);9117 }9118 elseif (strpos($input, './') === 0)9119 {9120 $input = substr($input, 2);9121 }9122 // B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise,9123 elseif (strpos($input, '/./') === 0)9124 {9125 $input = substr_replace($input, '/', 0, 3);9126 }9127 elseif ($input === '/.')9128 {9129 $input = '/';9130 }9131 // C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise,9132 elseif (strpos($input, '/../') === 0)9133 {9134 $input = substr_replace($input, '/', 0, 4);9135 $output = substr_replace($output, '', strrpos($output, '/'));9136 }9137 elseif ($input === '/..')9138 {9139 $input = '/';9140 $output = substr_replace($output, '', strrpos($output, '/'));9141 }9142 // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise,9143 elseif ($input === '.' || $input === '..')9144 {9145 $input = '';9146 }9147 // E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer9148 elseif (($pos = strpos($input, '/', 1)) !== false)9149 {9150 $output .= substr($input, 0, $pos);9151 $input = substr_replace($input, '', 0, $pos);9152 }9153 else9154 {9155 $output .= $input;9156 $input = '';9157 }9158 }9159 return $output . $input;9160 }9161 9162 9108 function get_element($realname, $string) 9163 9109 { 9164 9110 $return = array(); … … 11768 11714 } 11769 11715 11770 11716 /** 11771 * Remove dot segments from a path11772 *11773 * @access private11774 * @param string $input11775 * @return string11776 */11777 function remove_dot_segments($input)11778 {11779 $output = '';11780 while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..')11781 {11782 // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise,11783 if (strpos($input, '../') === 0)11784 {11785 $input = substr($input, 3);11786 }11787 elseif (strpos($input, './') === 0)11788 {11789 $input = substr($input, 2);11790 }11791 // B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise,11792 elseif (strpos($input, '/./') === 0)11793 {11794 $input = substr_replace($input, '/', 0, 3);11795 }11796 elseif ($input === '/.')11797 {11798 $input = '/';11799 }11800 // C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise,11801 elseif (strpos($input, '/../') === 0)11802 {11803 $input = substr_replace($input, '/', 0, 4);11804 $output = substr_replace($output, '', strrpos($output, '/'));11805 }11806 elseif ($input === '/..')11807 {11808 $input = '/';11809 $output = substr_replace($output, '', strrpos($output, '/'));11810 }11811 // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise,11812 elseif ($input === '.' || $input === '..')11813 {11814 $input = '';11815 }11816 // E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer11817 elseif (($pos = strpos($input, '/', 1)) !== false)11818 {11819 $output .= substr($input, 0, $pos);11820 $input = substr_replace($input, '', 0, $pos);11821 }11822 else11823 {11824 $output .= $input;11825 $input = '';11826 }11827 }11828 return $output . $input;11829 }11830 11831 /**11832 11717 * Replace invalid character with percent encoding 11833 11718 * 11834 11719 * @access private … … 12106 11991 else 12107 11992 { 12108 11993 $this->path = $this->replace_invalid_with_pct_encoding($path, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=@/'); 12109 if ($this->scheme !== null )11994 if ($this->scheme !== null && function_exists( 'remove_dot_segments' )) 12110 11995 { 12111 $this->path = $this->remove_dot_segments($this->path);11996 $this->path = remove_dot_segments($this->path); 12112 11997 } 12113 11998 $this->valid[__FUNCTION__] = true; 12114 11999 return true; -
wp-includes/formatting.php
716 716 } 717 717 718 718 /** 719 * Remove dot segments from a path 720 * 721 * @access private 722 * @param string $input 723 * @return string 724 */ 725 function remove_dot_segments($input) 726 { 727 $output = ''; 728 while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..') 729 { 730 // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise, 731 if (strpos($input, '../') === 0) 732 { 733 $input = substr($input, 3); 734 } 735 elseif (strpos($input, './') === 0) 736 { 737 $input = substr($input, 2); 738 } 739 // B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise, 740 elseif (strpos($input, '/./') === 0) 741 { 742 $input = substr_replace($input, '/', 0, 3); 743 } 744 elseif ($input === '/.') 745 { 746 $input = '/'; 747 } 748 // C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise, 749 elseif (strpos($input, '/../') === 0) 750 { 751 $input = substr_replace($input, '/', 0, 4); 752 $output = substr_replace($output, '', strrpos($output, '/')); 753 } 754 elseif ($input === '/..') 755 { 756 $input = '/'; 757 $output = substr_replace($output, '', strrpos($output, '/')); 758 } 759 // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise, 760 elseif ($input === '.' || $input === '..') 761 { 762 $input = ''; 763 } 764 // E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer 765 elseif (($pos = strpos($input, '/', 1)) !== false) 766 { 767 $output .= substr($input, 0, $pos); 768 $input = substr_replace($input, '', 0, $pos); 769 } 770 else 771 { 772 $output .= $input; 773 $input = ''; 774 } 775 } 776 return $output . $input; 777 } 778 779 /** 719 780 * Sanitize username stripping out unsafe characters. 720 781 * 721 782 * If $strict is true, only alphanumeric characters (as well as _, space, ., -, -
wp-includes/general-template.php
116 116 * @param string $slug The slug name for the generic template. 117 117 * @param string $name The name of the specialised template. 118 118 */ 119 function get_template_part( $slug, $name = null ) { 120 do_action( "get_template_part_{$slug}", $slug, $name ); 119 function get_template_part( $slug, $name = null, $directory = null ) { 120 if ( false !== strpos( $slug, DIRECTORY_SEPARATOR ) ) { 121 $original_slug = $slug; 122 $slug = substr( strrchr( $slug, DIRECTORY_SEPARATOR ), 1 ); 123 if ( empty( $directory ) ) { 124 $directory = substr( $original_slug, 0, strrpos( $original_slug, DIRECTORY_SEPARATOR ) ); 125 } 126 } 127 $slug = sanitize_file_name( $slug ); 121 128 129 $directory = rtrim( remove_dot_segments( $directory ), DIRECTORY_SEPARATOR ); 130 131 do_action( "get_template_part_{$slug}", $slug, $name, $directory ); 132 122 133 $templates = array(); 134 if ( ! empty( $directory ) ) { 135 if ( isset($name) ) 136 $templates[] = $directory . DIRECTORY_SEPARATOR . "{$slug}-{$name}.php"; 137 138 $templates[] = $directory . DIRECTORY_SEPARATOR . "{$slug}.php"; 139 } 140 123 141 if ( isset($name) ) 124 142 $templates[] = "{$slug}-{$name}.php"; 125 143 126 144 $templates[] = "{$slug}.php"; 127 145 128 locate_template( $templates, true, false);146 locate_template( $templates, true, false ); 129 147 } 130 148 131 149 /** … … 654 672 if ( ! is_post_type_archive() ) 655 673 return; 656 674 657 675 658 676 $post_type_obj = get_post_type_object( get_query_var( 'post_type' ) ); 659 677 $title = apply_filters('post_type_archive_title', $post_type_obj->labels->name ); 660 678 … … 663 681 else 664 682 return $title; 665 683 } 666 684 667 685 /** 668 686 * Display or retrieve page title for category archive. 669 687 *
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)