Ticket #23098: 23098.diff

File 23098.diff, 3.9 KB (added by DrewAPicture, 5 months ago)
Line 
1Index: wp-includes/link-template.php
2===================================================================
3--- wp-includes/link-template.php       (revision 23244)
4+++ wp-includes/link-template.php       (working copy)
5@@ -1865,6 +1865,22 @@
6 }
7 
8 /**
9+ * Append a path to a URL
10+ *
11+ * @package WordPress
12+ * @since 3.6.0
13+ *
14+ * @param      string $url URL to append a path to
15+ * @param      string $path (optional) Path relative to the home URL
16+ * @return string URL with optional path appended
17+ */
18+function append_path( $url, $path = '' ) {
19+       if ( ! empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
20+               $url = $url . '/' . ltrim( $path, '/' );
21+       return $url;
22+}
23+
24+/**
25  * Retrieve the home url for the current site.
26  *
27  * Returns the 'home' option with the appropriate protocol, 'https' if
28@@ -1919,8 +1935,7 @@
29 
30        $url = set_url_scheme( $url, $scheme );
31 
32-       if ( ! empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
33-               $url .= '/' . ltrim( $path, '/' );
34+       $url = append_path( $url, $path );
35 
36        return apply_filters( 'home_url', $url, $path, $orig_scheme, $blog_id );
37 }
38@@ -1971,8 +1986,7 @@
39 
40        $url = set_url_scheme( $url, $scheme );
41 
42-       if ( ! empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
43-               $url .= '/' . ltrim( $path, '/' );
44+       $url = append_path( $url, $path );
45 
46        return apply_filters( 'site_url', $url, $path, $scheme, $blog_id );
47 }
48@@ -2005,8 +2019,7 @@
49 function get_admin_url( $blog_id = null, $path = '', $scheme = 'admin' ) {
50        $url = get_site_url($blog_id, 'wp-admin/', $scheme);
51 
52-       if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
53-               $url .= ltrim( $path, '/' );
54+       $url = append_path( $url, $path );
55 
56        return apply_filters( 'admin_url', $url, $path, $blog_id );
57 }
58@@ -2023,8 +2036,7 @@
59 function includes_url($path = '') {
60        $url = site_url() . '/' . WPINC . '/';
61 
62-       if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
63-               $url .= ltrim($path, '/');
64+       $url = append_path( $url, $path );
65 
66        return apply_filters('includes_url', $url, $path);
67 }
68@@ -2041,8 +2053,7 @@
69 function content_url($path = '') {
70        $url = set_url_scheme( WP_CONTENT_URL );
71 
72-       if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
73-               $url .= '/' . ltrim($path, '/');
74+       $url = append_path( $url, $path );
75 
76        return apply_filters('content_url', $url, $path);
77 }
78@@ -2080,8 +2091,7 @@
79                        $url .= '/' . ltrim($folder, '/');
80        }
81 
82-       if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
83-               $url .= '/' . ltrim($path, '/');
84+       $url = append_path( $url, $path );
85 
86        return apply_filters('plugins_url', $url, $path, $plugin);
87 }
88@@ -2111,8 +2121,7 @@
89        else
90                $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme );
91 
92-       if ( ! empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
93-               $url .= ltrim( $path, '/' );
94+       $url = append_path( $url, $path );
95 
96        return apply_filters( 'network_site_url', $url, $path, $scheme );
97 }
98@@ -2147,8 +2156,7 @@
99        else
100                $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme );
101 
102-       if ( ! empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
103-               $url .= ltrim( $path, '/' );
104+       $url = append_path( $url, $path );
105 
106        return apply_filters( 'network_home_url', $url, $path, $orig_scheme);
107 }
108@@ -2169,8 +2177,7 @@
109 
110        $url = network_site_url('wp-admin/network/', $scheme);
111 
112-       if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
113-               $url .= ltrim($path, '/');
114+       $url = append_path( $url, $path );
115 
116        return apply_filters('network_admin_url', $url, $path);
117 }
118@@ -2188,8 +2195,7 @@
119 function user_admin_url( $path = '', $scheme = 'admin' ) {
120        $url = network_site_url('wp-admin/user/', $scheme);
121 
122-       if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
123-               $url .= ltrim($path, '/');
124+       $url = append_path( $url, $path );
125 
126        return apply_filters('user_admin_url', $url, $path);
127 }