Make WordPress Core


Ignore:
Timestamp:
09/29/2023 03:05:40 PM (8 months ago)
Author:
adamsilverstein
Message:

Revisions: slash meta values for autosave (preview) revisions.

Correct an issue where meta values containing characters like quote could not be previewed on published posts. The function update_metadata expects data to be slashed.

Also, add a test to confirm that storing JSON data which requires slashing in autosave meta works as expected, and improve naming for a data provider added in [56714].

Follow up to [56714].

Props mukesh27, spacedmonkey.
Fixes #20564.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php

    r56714 r56745  
    422422            foreach ( $revisioned_meta_keys as $meta_key ) {
    423423                if ( isset( $meta[ $meta_key ] ) ) {
    424                     update_metadata( 'post', $revision_id, $meta_key, $meta[ $meta_key ] );
     424                    update_metadata( 'post', $revision_id, $meta_key, wp_slash( $meta[ $meta_key ] ) );
    425425                }
    426426            }
Note: See TracChangeset for help on using the changeset viewer.