Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Format php.
  • Loading branch information
jffng committed Nov 16, 2023
commit 58f65d4e8e954493608fdaaf7022cf12896b5ae5
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ private function sanitize() {
'version' => '2',
'settings' => array(
'typography' => array(
'fontFamilies' => array(
'fontFamilies' => array(
'custom' => array(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The custom key is necessary to accommodate the input expected by remove_insecure_properties.

$this->data,
),
Expand All @@ -310,7 +310,7 @@ private function sanitize() {
);
// Creates a new WP_Theme_JSON object with the new fonts to
// leverage sanitization and validation.
$fonts_json = WP_Theme_JSON_Gutenberg::remove_insecure_properties( $fonts_json );
$fonts_json = WP_Theme_JSON_Gutenberg::remove_insecure_properties( $fonts_json );
$theme_json = new WP_Theme_JSON_Gutenberg( $fonts_json );
$theme_data = $theme_json->get_data();
$sanitized_font = ! empty( $theme_data['settings']['typography']['fontFamilies'] )
Expand Down
22 changes: 11 additions & 11 deletions phpunit/class-wp-theme-json-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -899,19 +899,19 @@ public function test_remove_invalid_element_pseudo_selectors() {
public function test_remove_invalid_font_family_settings() {
$actual = WP_Theme_JSON_Gutenberg::remove_insecure_properties(
array(
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
'settings' => array(
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
'settings' => array(
'typography' => array(
'fontFamilies' => array(
'custom' => array(
array(
'name' => 'Open Sans',
'slug' => 'open-sans',
'name' => 'Open Sans',
'slug' => 'open-sans',
'fontFamily' => '"Open Sans", sans-serif</style><script>alert("xss")</script>',
),
array(
'name' => 'Arial',
'slug' => 'arial',
'name' => 'Arial',
'slug' => 'arial',
'fontFamily' => 'Arial, serif',
),
),
Expand All @@ -923,18 +923,18 @@ public function test_remove_invalid_font_family_settings() {
);

$expected = array(
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
'settings' => array(
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
'settings' => array(
'typography' => array(
'fontFamilies' => array(
'custom' => array(
array(
'name' => 'Arial',
'slug' => 'arial',
'name' => 'Arial',
'slug' => 'arial',
'fontFamily' => 'Arial, serif',
),
),
)
),
),
),
);
Expand Down