#60360 closed task (blessed) (fixed)
Make WP_Theme_JSON to sanitize data on indexed arrays
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.5 | Priority: | normal |
Severity: | normal | Version: | 6.5 |
Component: | Editor | Keywords: | gutenberg-merge has-patch has-unit-tests |
Focuses: | Cc: |
Description
Currently, WP_Theme_JSON sanitization is not able to sanitize data contained on indexed arrays. So certain data from theme.json, for example, settings.typography.fontFamilies which is a JSON array, cannot be sanitized. Why? because when parsing the JSON data WP_Theme_JSON translates JSON arrays into PHP indexed arrays and the class is not capable of sanitizing that kind of data.
I think it would be useful to add nested indexed array schema sanitization capabilities to the WP_Theme_JSON class. For that reason, this ticket is aimed to bring that capability into core from WP_Theme_JSON_Gutenberg.
Change History (13)
This ticket was mentioned in PR #5957 on WordPress/wordpress-develop by matiasbenedetto.
16 months ago
#1
#2
@
16 months ago
- Owner set to youknowriad
- Resolution set to fixed
- Status changed from new to closed
In 57496:
@youknowriad commented on PR #5957:
16 months ago
#4
#6
follow-up:
↓ 8
@
16 months ago
I wonder instead of creating a new method is_assoc
, we could simply use array_is_list
( which can be used in core since [57337]) or maybe wp_is_numeric_array
?
This ticket was mentioned in PR #6007 on WordPress/wordpress-develop by @mmaattiiaass.
16 months ago
#7
- Remove custom
is_assoc
method and replace it by thewp_is_numeric_array
. - Simplify the code by reverting the order of an
if
andelse
to avoid using!wp_is_numeric_array()
and isnstead usewp_is_numeric_array()
props to @spacedmonkey that suggested the user of wp_is_numeric_array
https://core.trac.wordpress.org/ticket/60360#comment:6
#8
in reply to:
↑ 6
@
16 months ago
Replying to spacedmonkey:
I wonder instead of creating a new method
is_assoc
, we could simply usearray_is_list
( which can be used in core since [57337]) or maybewp_is_numeric_array
?
Yes, good idea, thanks for pointing that out.
I implemented the suggested change here: https://github.com/WordPress/wordpress-develop/pull/6007
This ticket was mentioned in Slack in #core by chaion07. View the logs.
15 months ago
#10
@
15 months ago
- Type changed from enhancement to task (blessed)
Marking as task for the follow-up polish required here.
#11
@
15 months ago
I don't really like this protected is_assoc
method either, so let's make sure we fix this in 6.5.
@swissspidy commented on PR #6007:
15 months ago
#13
Committed in https://core.trac.wordpress.org/changeset/57751
## What?
WP_Theme_JSON
:## Why?
Currently,
WP_Theme_JSON
sanitization is not able to sanitize data contained on indexed arrays. So certain data fromtheme.json
, for example,settings.typography.fontFamilies
which is a JSON array, cannot be sanitized. Why? because when parsing the JSON dataWP_Theme_JSON
class translates JSON arrays into PHP indexed arrays and the it is not capable of sanitizing that kind of data.---
Trac ticket: https://core.trac.wordpress.org/ticket/60360#