[wp-trac] [WordPress Trac] #4273: Posting comments to pages with øæå redirects to a 404 page

WordPress Trac wp-trac at lists.automattic.com
Wed May 16 09:01:52 GMT 2007


#4273: Posting comments to pages with øæå redirects to a 404 page
---------------------+------------------------------------------------------
 Reporter:  orvar    |       Owner:  anonymous
     Type:  defect   |      Status:  new      
 Priority:  high     |   Milestone:  2.2.1    
Component:  General  |     Version:  2.1.3    
 Severity:  normal   |    Keywords:           
---------------------+------------------------------------------------------
 [This is a repost of a ticket from the WPMU trac:
 http://trac.mu.wordpress.org/ticket/305]

 === How to reproduce ===
  * Create a page with a name that contains non-ascii characters (eg. øæå)
 that are not replaced with ascii characters in the slug.
  * Post a comment on that page.

 The comment is saved but the user is not returned to the page. Instead he
 gets a 404 page not found error. After the comment has been saved to the
 db the user is redirected to a url where the specific non-asci characters
 are simply missing.

 === How to fix ===

 This happens because `get_permalink` for a page returns a page name that
 has been urldecoded. Which is fine for links (old browsers?) but does not
 work in a `Location:` header.

 Change `get_page_uri` in `wp-includes/post.php` to:
 {{{
 function get_page_uri($page_id, $decode = true) {
         $page = get_page($page_id);
         $uri = ( $decode ) ? urldecode($page->post_name) :
 $page->post_name;

         // A page cannot be it's own parent.
         if ( $page->post_parent == $page->ID )
                 return $uri;

         while ($page->post_parent != 0) {
                 $page = get_page($page->post_parent);
                 $uri = ( $decode ) ? urldecode($page->post_name) . "/" .
 $uri : $page->post_name . "/" . $uri;
         }

         return $uri;
 }
 }}}

 Change the call to `get_page_uri` in the function `_get_page_link` in `wp-
 includes/link-template.php` to:


 {{{
                 $link = get_page_uri($id, false);
 }}}

 I will try to post a diff for 2.2 later if nobody beats me to it.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/4273>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list