From bf3b6b800d56148e0253a3e4d80b61862295f95c Mon Sep 17 00:00:00 2001 From: Nikolay Bachiyski Date: Tue, 21 Jun 2016 14:51:29 +0000 Subject: [PATCH] Admin: escape URL-encoded permalinks Merge of [37801] to the 4.4 branch. Built from https://develop.svn.wordpress.org/branches/4.4@37807 git-svn-id: http://core.svn.wordpress.org/branches/4.4@37772 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/post.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 4eb6a48a5a..fb946868d1 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -1309,7 +1309,7 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { $view_link = get_permalink( $post ); } else { // Allow non-published (private, future) to be viewed at a pretty permalink. - $view_link = str_replace( array( '%pagename%', '%postname%' ), $post->post_name, urldecode( $permalink ) ); + $view_link = str_replace( array( '%pagename%', '%postname%' ), $post->post_name, $permalink ); } } } @@ -1319,7 +1319,8 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { $return = '' . __( 'Permalink:' ) . "\n"; if ( false !== $view_link ) { - $return .= '' . $view_link . "\n"; + $display_link = urldecode( $view_link ); + $return .= '' . esc_html( $display_link ) . "\n"; } else { $return .= '' . $permalink . "\n"; } @@ -1343,14 +1344,14 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { } } - $post_name_html = '' . $post_name_abridged . ''; - $display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, urldecode( $permalink ) ); + $post_name_html = '' . esc_html( $post_name_abridged ) . ''; + $display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, esc_html( urldecode( $permalink ) ) ); $return = '' . __( 'Permalink:' ) . "\n"; $return .= '' . $display_link . "\n"; $return .= '‎'; // Fix bi-directional text display defect in RTL languages. $return .= '\n"; - $return .= '' . $post_name . "\n"; + $return .= '' . esc_html( $post_name ) . "\n"; } /** @@ -1847,4 +1848,4 @@ function redirect_post($post_id = '') { */ wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) ); exit; -} \ No newline at end of file +}