[wp-trac] [WordPress Trac] #17923: add_query_arg() should encode values

WordPress Trac wp-trac at lists.automattic.com
Tue Jun 28 22:55:50 UTC 2011


#17923: add_query_arg() should encode values
--------------------------+-----------------------------
 Reporter:  Viper007Bond  |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 One (or me at least) would expect that the result of

 {{{
 add_query_arg( 'foobar', 'this&that', 'index.php' )
 }}}

 would be

 {{{
 index.php?foobar=this%26that
 }}}

 since the whole purpose of the function is to build a URL. However the
 actual result is

 {{{
 index.php?foobar=this&that
 }}}

 You're asking to the function to create a URL in which `foobar` is
 `this&that` but instead it creates a URL in which `foobar` is set to only
 `this`. You shouldn't have to pre-encode values -- the function should
 take care of it for you.

 The function to "blame" for this is our `build_query()` which for some
 reason does not encode by default.

 Semi-related: #16943

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


More information about the wp-trac mailing list