[wp-trac] [WordPress Trac] #54840: wp_insert_term sanitizes attribute names, while term_exists does not before checking names
WordPress Trac
noreply at wordpress.org
Mon Jan 17 08:29:27 UTC 2022
#54840: wp_insert_term sanitizes attribute names, while term_exists does not before
checking names
--------------------------+-----------------------------
Reporter: Dekadinious | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: 5.8.2
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
We have found an edge-case bug in the way term_exists handles checking for
existing names compared to how wp_insert_term inserts the names. This
happens if you are in a situation where the term name has an ampersand,
and term_exists reach the point where it needs to check for the name. This
happened to us because we have a suffix on each term slug.
So if we are creating the term "X & Y", the slug will be "x-y-suffix".
Therefore, there is no "x-y" slug in the database. The term_exists
function will therefore not find the slug and will check for the name
instead.
When checking for the name, it will see if "X & Y" exists in the database.
It does not, because wp_insert_term sanitizes the name and inserts it as
"X & Y".
The behavior is inconsistent. I would expect term_exist to find that the
term exists when checking for the exact name used in wp_insert_term.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54840>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list