[wp-trac] [WordPress Trac] #41211: When the /category/category-name portion is repeated in the URL, it serves content instead of 404
WordPress Trac
noreply at wordpress.org
Tue Feb 22 13:43:41 UTC 2022
#41211: When the /category/category-name portion is repeated in the URL, it serves
content instead of 404
---------------------------+------------------------------
Reporter: sjwright1986 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Rewrite Rules | Version: 4.8
Severity: normal | Resolution:
Keywords: needs-patch | Focuses:
---------------------------+------------------------------
Comment (by enshrined):
This issue also exists when you use a custom permalink structure such as:
`/%category%/%postname%/`. I'm using category as an example here, but this
would happen for all hierarchical taxonomies.
Due to how the rewrites are added, when `%category%` appears first in the
permalink structure, we get the following rule added `category/(.+?)/?$`.
Due to the openness of the regex used for hierarchical taxonomies, it will
match anything between the `/category` and the end of the URL.
For example, set up a category with the slug `testing`. It should only be
accessible at:
* `/category/testing/`
It's actually accessible at `/category/(.+?)/testing`. In practice, this
could look like any of the following:
* `/category/asdf/testing`
* `/category/asdf/1234/testing`
* `/category/asdf/1234/xy-z/testing`
I agree with @bradleyt here; taxonomies should have a function like
`get_page_by_path()` that can double-check that the path in use correctly
matches that of a term.
There's a patch incoming that should handle this.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41211#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list