From 3a736df922c2310f4702c337013ca00282a72fae Mon Sep 17 00:00:00 2001 From: Nikolay Bachiyski Date: Tue, 21 Jun 2016 14:49:37 +0000 Subject: [PATCH] Admin: escape URL-encoded permalinks Merge of [37801] to the 4.4 branch. git-svn-id: https://develop.svn.wordpress.org/branches/4.4@37807 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/post.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php index 4eb6a48a5a..fb946868d1 100644 --- a/src/wp-admin/includes/post.php +++ b/src/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 +}