Make WordPress Core

Opened 19 years ago

Closed 18 years ago

Last modified 17 years ago

#2406 closed defect (bug) (invalid)

add_query_arg() does not return Strict XHTML links.

Reported by: majelbstoat's profile majelbstoat Owned by: markjaquith's profile markjaquith
Milestone: Priority: normal
Severity: normal Version: 2.0.1
Component: Administration Keywords: add_query_arg ampersand xhtml strict bg|has-patch
Focuses: Cc:

Description

add_query_arg() is a useful general purpose function that can be employed to extend a query string if it already exists. However, the appending of new variables is done with '&' rather than '&', which means that links returned are not XHTML Strict 1.0 or XHTML 1.1 compliant. This is not important for wp-admin pages, but causes problems on site pages. Parsing errors in Firefox and possible more browsers cause the site not to be visible, returning only an XML error. The following patch alters add_query_arg() to append using the correct '&' connector, which would greatly enhance its usability for plugins that wish to work with links.

Attachments (1)

add valid ampersands.diff (508 bytes) - added by majelbstoat 19 years ago.
add & instead of &

Download all attachments as: .zip

Change History (11)

@majelbstoat
19 years ago

add & instead of &

#1 @majelbstoat
19 years ago

An alternative solution would be to add a 'strict = false' final argument which would determine whether to output & or &. This might necessitate a refactoring of the argument handling code at the top.

#2 @markjaquith
19 years ago

  • Owner changed from anonymous to markjaquith
  • Status changed from new to assigned

+1

XHTML validity is one of WordPress' big things. Don't have time to give this a thorough look now, but I'll return to it.

#3 @davidhouse
19 years ago

Might break if we use it in HTTP, for example. I recommend adding a parameter which is on by default.

#4 @ryan
19 years ago

Or leave it alone and run the output through urlencode() if so needed.

#5 @davidhouse
19 years ago

I assume you mean htmlentities ;)

#6 @markjaquith
19 years ago

er, yeah.

#7 @Viper007Bond
19 years ago

Yeah, that's what I ended up doing.

And will using & break HTML?

#8 @davidhouse
19 years ago

No, that's not what I said. It will break if used in HTTP headers sent with a header() call.

#9 @matt
18 years ago

  • Resolution set to invalid
  • Status changed from assigned to closed

Yes we should do this on a different level, so we don't break redirects.

#10 @Nazgul
17 years ago

  • Milestone 2.1 deleted
Note: See TracTickets for help on using tickets.