Skip to content
Merged
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
Next Next commit
Add test case to remove insecure font family.
  • Loading branch information
jffng committed Nov 16, 2023
commit 3a207b3dd7d88f77b26452269f4602c017059e08
46 changes: 46 additions & 0 deletions phpunit/class-wp-theme-json-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,52 @@ public function test_remove_invalid_element_pseudo_selectors() {
$this->assertEqualSetsWithIndex( $expected, $actual );
}

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(
'typography' => array(
'fontFamilies' => array(
'custom' => array(
array(
'name' => 'Open Sans',
'slug' => 'open-sans',
'fontFamily' => '"Open Sans", sans-serif</style><script>alert("xss")</script>',
),
array(
'name' => 'Arial',
'slug' => 'arial',
'fontFamily' => 'Arial, serif',
),
),
),
),
),
),
true
);

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

$this->assertEqualSetsWithIndex( $expected, $actual );
}

public function test_get_element_class_name_button() {
$expected = 'wp-element-button';
$actual = WP_Theme_JSON_Gutenberg::get_element_class_name( 'button' );
Expand Down