[wp-trac] [WordPress Trac] #36387: Function: term_exists() fails on children with ampersand

WordPress Trac noreply at wordpress.org
Thu Mar 31 16:55:08 UTC 2016


#36387: Function: term_exists() fails on children with ampersand
-------------------------+-------------------------------------------------
 Reporter:  Howdy_McGee  |       Owner:
     Type:  defect       |      Status:  closed
  (bug)                  |   Milestone:
 Priority:  normal       |     Version:  4.4.2
Component:  Taxonomy     |  Resolution:  duplicate
 Severity:  normal       |     Focuses:  administration, template,
 Keywords:               |  performance
-------------------------+-------------------------------------------------
Changes (by boonebgorges):

 * status:  new => closed
 * resolution:   => duplicate
 * milestone:  Awaiting Review =>


Comment:

 Hi @Howdy_McGee - Thanks for the ticket.

 This issue has been discussed previously in
 https://core.trac.wordpress.org/ticket/32248#comment:9, and broadly falls
 under #11311. Briefly, when you create a tag `Foo & Bar` through the
 post.php interface (or elsewhere in the Dashboard, I think), sanitization
 routines run on the `name` field before it's saved. Specifically,
 `sanitize_term_field()` causes `_wp_specialchars()` to HTML-encode the
 ampersand. So `Foo & Bar` in the interface ends up as `Foo & Bar` in
 the database.

 Whether it's wise for us to be HTML-encoding term names before saving is a
 question for #11311. For your purposes, you should run raw content through
 `sanitize_term_field()` before passing to `term_exists()`, so that your
 call looks like `term_exists( 'Foo & Bar' )`

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36387#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list