Skip to content

Commit

Permalink
Unslash post content before parsing during save
Browse files Browse the repository at this point in the history
Fixes #3426
  • Loading branch information
mcsf committed Nov 13, 2017
1 parent 04ef252 commit adf94b4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,15 @@ function gutenberg_wpautop_block_content( $content ) {
*/
function gutenberg_wpautop_insert_post_data( $data ) {
if ( ! empty( $data['post_content'] ) && gutenberg_content_has_blocks( $data['post_content'] ) ) {
$data['post_content'] = gutenberg_wpautop_block_content( $data['post_content'] );
// WP_REST_Posts_Controller slashes post data before inserting/updating
// a post. This data gets unslashed by `wp_insert_post` right before
// saving to the DB. The PEG parser needs unslashed input in order to
// properly parse JSON attributes.
$content = wp_unslash( $data['post_content'] );
$content = gutenberg_wpautop_block_content( $content );
$content = wp_slash( $content );

$data['post_content'] = $content;
}

return $data;
Expand Down

0 comments on commit adf94b4

Please sign in to comment.