Opened 8 years ago
Closed 8 years ago
#38766 closed defect (bug) (fixed)
Post type templates ignore the last post type if there is a trailing full stop.
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.7 | Priority: | normal |
Severity: | normal | Version: | 4.7 |
Component: | Posts, Post Types | Keywords: | has-patch has-unit-tests commit |
Focuses: | template | Cc: |
Description
Trailing full stops can cause the template post type comment to ignore the final post type.
// Works Template post type: page, post // Fails Template post type: page, post.
Incoming patch modifies the regular expression to exclude any trailing full stops and trailing whitespace.
Attachments (3)
Change History (11)
#3
@
8 years ago
- Keywords has-unit-tests 2nd-opinion added; needs-unit-tests removed
Unit tests added in 38766.2.diff.
After a second opinion, is regex's u
modifier bad for performance?
#4
@
8 years ago
- Keywords needs-refresh needs-unit-tests added; has-unit-tests 2nd-opinion removed
Some things:
- If we're going to change how this works, I think the correct way would be to use
sanitize_key()
on the post type, the same asregister_post_type()
does. So, instead of$type = trim( $type );
, have$type = sanitize_key( $type );
. That removes the need for changing the regex. - The tests don't test for trailing spaces. The tests could probably be expanded to test for other invalid characters.
- The
U
modifier (invert greediness) is not the same as theu
modifier (UTF-8 compatibility). The former is incorrect, and we don't need to use the latter, as only a subset of ASCII characters are allowed in post types.
#5
@
8 years ago
- Keywords has-unit-tests added; needs-refresh needs-unit-tests removed
@pento thanks for the regex explanation.
In 38766.3.diff:
- additional tests for trailing punctuation and white space.
- switch to
sanitize_key()
- test to ensure invalid character ignored.
#6
@
8 years ago
- Keywords commit added
- Owner set to peterwilsoncc
- Status changed from new to assigned
:thumbs-up:
This ticket was mentioned in Slack in #core by peterwilsoncc. View the logs.
8 years ago
Note: See
TracTickets for help on using
tickets.
Missed it by this much... :0