Make WordPress Core


Ignore:
Timestamp:
11/08/2016 05:54:22 AM (9 years ago)
Author:
rmccue
Message:

REST API: Respect unfiltered_html for HTML post fields.

This necessitates a change to our slashing code as well. Ah slashing, the cause of, and solution to, all of life's problems.

Props jnylen0.
Fixes #38609.

File:
1 edited

Legend:

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

    r39126 r39155  
    489489
    490490        $post->post_type = $this->post_type;
    491         $post_id         = wp_insert_post( $post, true );
     491        $post_id         = wp_insert_post( wp_slash( (array) $post ), true );
    492492
    493493        if ( is_wp_error( $post_id ) ) {
     
    629629
    630630        // convert the post object to an array, otherwise wp_update_post will expect non-escaped input.
    631         $post_id = wp_update_post( (array) $post, true );
     631        $post_id = wp_update_post( wp_slash( (array) $post ), true );
    632632
    633633        if ( is_wp_error( $post_id ) ) {
     
    970970        if ( ! empty( $schema['properties']['title'] ) && isset( $request['title'] ) ) {
    971971            if ( is_string( $request['title'] ) ) {
    972                 $prepared_post->post_title = wp_filter_post_kses( $request['title'] );
     972                $prepared_post->post_title = $request['title'];
    973973            } elseif ( ! empty( $request['title']['raw'] ) ) {
    974                 $prepared_post->post_title = wp_filter_post_kses( $request['title']['raw'] );
     974                $prepared_post->post_title = $request['title']['raw'];
    975975            }
    976976        }
     
    979979        if ( ! empty( $schema['properties']['content'] ) && isset( $request['content'] ) ) {
    980980            if ( is_string( $request['content'] ) ) {
    981                 $prepared_post->post_content = wp_filter_post_kses( $request['content'] );
     981                $prepared_post->post_content = $request['content'];
    982982            } elseif ( isset( $request['content']['raw'] ) ) {
    983                 $prepared_post->post_content = wp_filter_post_kses( $request['content']['raw'] );
     983                $prepared_post->post_content = $request['content']['raw'];
    984984            }
    985985        }
     
    988988        if ( ! empty( $schema['properties']['excerpt'] ) && isset( $request['excerpt'] ) ) {
    989989            if ( is_string( $request['excerpt'] ) ) {
    990                 $prepared_post->post_excerpt = wp_filter_post_kses( $request['excerpt'] );
     990                $prepared_post->post_excerpt = $request['excerpt'];
    991991            } elseif ( isset( $request['excerpt']['raw'] ) ) {
    992                 $prepared_post->post_excerpt = wp_filter_post_kses( $request['excerpt']['raw'] );
     992                $prepared_post->post_excerpt = $request['excerpt']['raw'];
    993993            }
    994994        }
Note: See TracChangeset for help on using the changeset viewer.