Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/12/2024 01:00:20 PM (3 years ago)
Author:
espellcaste
Message:

Strip slashes from a BP_XProfile_ProfileData field value only if the field is serialized.

This change makes sure that XProfile fields with serialized data correctly keeps the string with apostrophes.

Props imath and niftythree
See ​https://github.com/buddypress/BP-REST/pull/497
Closes ​https://github.com/buddypress/buddypress/pull/268
Fixes #9127

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-profiledata.php

    r13475 r13791  
    7777         *
    7878         * @since 1.0.0
    79          * 
     79         *
    8080         * @global wpdb $wpdb WordPress database object.
    8181         *
    … …  
    104104                        $this->user_id      = (int) $profiledata->user_id;
    105105                        $this->field_id     = (int) $profiledata->field_id;
    106                         $this->value        = stripslashes( $profiledata->value );
    107106                        $this->last_updated = $profiledata->last_updated;
    108107
     108                        // If the value is serializable, do not stripslashes.
     109                        $this->value        = is_serialized( $profiledata->value ) ? $profiledata->value : stripslashes( $profiledata->value );
    109110                } else {
    110111                        // When no row is found, we'll need to set these properties manually.
    … …  
    178179         *
    179180         * @since 1.0.0
    180          * 
     181         *
    181182         * @global wpdb $wpdb WordPress database object.
    182183         *
    … …  
    322323         * @since 8.0.0 Checks if a null field data is an xProfile WP Field.
    323324         *              Adds a new parameter `$field_type_objects` to pass the list of field type objects.
    324          * 
     325         *
    325326         * @global wpdb $wpdb WordPress database object.
    326327         *
    … …  
    481482         *
    482483         * @since 1.6.0
    483          * 
     484         *
    484485         * @global wpdb $wpdb WordPress database object.
    485486         *
    … …  
    516517         * @since 1.0.0
    517518         * @since 8.0.0 Checks if a null field data is an xProfile WP Field.
    518          * 
     519         *
    519520         * @global wpdb $wpdb WordPress database object.
    520521         *
    … …  
    626627         *
    627628         * @since 1.0.0
    628          * 
    629          * @global wpdb $wpdb WordPress database object.
    630          * 
     629         *
     630         * @global wpdb $wpdb WordPress database object.
     631         *
    631632         * @deprecated 8.0.0 This function is not used anymore.
    632633         *
    … …  
    695696         *
    696697         * @since 1.0.0
    697          * 
     698         *
    698699         * @global wpdb $wpdb WordPress database object.
    699700         *
    … …  
    717718         *
    718719         * @since 1.0.0
    719          * 
     720         *
    720721         * @global wpdb $wpdb WordPress database object.
    721722         *
    … …  
    737738         *
    738739         * @since 1.0.0
    739          * 
     740         *
    740741         * @global wpdb $wpdb WordPress database object.
    741742         *
    … …  
    765766         *
    766767         * @since 1.0.0
    767          * 
     768         *
    768769         * @global wpdb $wpdb WordPress database object.
    769770         *
Note: See TracChangeset for help on using the changeset viewer.