[wp-trac] [WordPress Trac] #18274: Add_query_arg doesn't cope with guid in url ie &p= becomes #038; p=

WordPress Trac wp-trac at lists.automattic.com
Thu Aug 11 20:23:37 UTC 2011


#18274: Add_query_arg doesn't cope with guid in url  ie &p= becomes #038;p=
--------------------------+------------------------------
 Reporter:  anmari        |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:  3.2.1
 Severity:  trivial       |  Resolution:
 Keywords:                |
--------------------------+------------------------------

Comment (by nathanrice):

 Happening for me too. In my case, I've got a custom post type created
 (we'll call it "restaurant"). I've got a settings page as a submenu of
 "Restaurant". To pull the URL to the settings page I use `menu_page_url(
 'restaurant-settings', 0 );` which gives me this:

 {{{http://example.com/wp-admin/edit.php?post_type=restaurant&page
 =restaurant-settings}}}

 Actually, the source looks like this:

 {{{http://example.com/wp-admin/edit.php?post_type=restaurant&page
 =restaurant-settings}}}

 Here comes the bug. When I save the settings, I use `add_query_arg()` and
 `wp_redirect()` to add an updated flag to the URL, so I can push an admin
 notice.

 When I do, the resulting URL to which the user is redirected looks like
 this:

 {{{http://example.com/wp-
 admin/edit.php?post_type=restaurant&updated=true#038;page=restaurant-
 settings}}}

 `add_query_arg()` is getting confused when it sees `&` and completely
 borks the result.

 The obvious solution is to not use URLs with character entities in them,
 or if the URL is generated, run it through `html_entity_decode()` before
 passing it to `add_query_arg()`.

 So, it IS a bug, but I'm not sure how serious it is, or whether it's a
 regression.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18274#comment:8>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list