Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global styles: update PHP unit tests #52819

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,26 @@ protected function prepare_item_for_database( $request ) {
return $changes;
}

/**
* Validate style.css as valid CSS.
*
* Currently just checks for invalid markup.
*
* @since 6.2.0
* @since 6.4.0 Changed method visibility to protected.
*
* @param string $css CSS to validate.
* @return true|WP_Error True if the input was validated, otherwise WP_Error.
*/
protected function validate_custom_css( $css ) {
if ( preg_match( '#</?\w+#', $css ) ) {
return new WP_Error(
'rest_custom_css_illegal_markup',
__( 'Markup is not allowed in CSS.', 'gutenberg' ),
array( 'status' => 400 )
);
}
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Gutenberg_REST_Global_Styles_Revisions_Controller_6_4 extends Gutenberg_RE
* Prepares the revision for the REST response.
*
* @since 6.3.0
* @since 6.4.0 Added `behaviors` field to the response.
*
* @param WP_Post $post Post revision object.
* @param WP_REST_Request $request Request object.
Expand Down Expand Up @@ -87,6 +88,7 @@ public function prepare_item_for_response( $post, $request ) {
* Retrieves the revision's schema, conforming to JSON Schema.
*
* @since 6.3.0
* @since 6.4.0 Added `behaviors` field to the schema properties.
*
* @return array Item schema data.
*/
Expand Down
Loading
Loading