Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/23/2013 06:47:16 PM (11 years ago)
Author:
boonebgorges
Message:

Sanitize more gently in component *_update_meta() functions

Previous sanitization techniques resulted in double-sanitization. Recent
changes in how WP's SQL sanitization routines work have surfaced this problem,
in particular as regards line breaks. By removing the extraneous call to
esc_sql(), we ensure that line breaks are preserved, and sanitization is left
to $wpdb->prepare().

Change applied in update_meta() functions through bp-groups, bp-activity, and
bp-xprofile. Also adds corresponding unit tests.

Fixes #5180

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/testcases/xprofile/functions.php

    r7365 r7469  
    6363        $this->set_current_user( $old_current_user );
    6464    }
     65
     66    /**
     67     * @group bp_xprofile_update_meta
     68     * @ticket BP5180
     69     */
     70    public function test_bp_xprofile_update_meta_with_line_breaks() {
     71        $g = $this->factory->xprofile_group->create();
     72        $f = $this->factory->xprofile_field->create( array(
     73            'field_group_id' => $g->id,
     74            'type' => 'textbox',
     75        ) );
     76
     77        $meta_value = 'Foo!
     78
     79Bar!';
     80        bp_xprofile_update_meta( $f->id, 'field', 'linebreak_field', $meta_value );
     81        $this->assertEquals( $meta_value, bp_xprofile_get_meta( $f->id, 'field', 'linebreak_field' ) );
     82    }
    6583}
Note: See TracChangeset for help on using the changeset viewer.