Skip to:
Content

BuddyPress.org

Ticket #6346: 6346.hex.patch

File 6346.hex.patch, 1.7 KB (added by r-a-y, 10 years ago)
  • src/bp-activity/bp-activity-functions.php

     
    16611661                                                                                ? $r['action']
    16621662                                                                                : bp_activity_generate_action_string( $activity );
    16631663
    1664         if ( ! $activity->save() ) {
     1664        $success = $activity->save();
     1665
     1666        // If the save failed, see if we can sanity check the main fields and try again
     1667        if ( ! $success && is_callable( array( $GLOBALS['wpdb'], 'strip_invalid_text_for_column' ) ) ) {
     1668                $fields = array( 'content' );
     1669
     1670                foreach( $fields as $field ) {
     1671                        if ( isset( $activity->$field ) ) {
     1672                                $activity->$field = $GLOBALS['wpdb']->strip_invalid_text_for_column( buddypress()->activity->table_name, $field, $activity->$field );
     1673                        }
     1674                }
     1675
     1676                $success = $activity->save();
     1677        }
     1678
     1679        if ( ! $success ) {
    16651680                return false;
    16661681        }
    16671682
  • tests/phpunit/testcases/activity/functions.php

     
    55class BP_Tests_Activity_Functions extends BP_UnitTestCase {
    66
    77        /**
     8         * @ticket BP6346
     9         */
     10        public function test_bp_activity_add_and_hex_a_to_f_characters() {
     11                $a = $this->factory->activity->create( array(
     12                        'type' => 'activity_update',
     13
     14                        // you can switch out %E9 with any A-F prefixed character.
     15                        // http://www.ascii.cl/htmlcodes.htm
     16                        'content' => urldecode( 'hey hey %E9' )
     17                ) );
     18
     19                $this->assertNotFalse( $a, 'bp_activity_add() failed to insert content with hex A-F characters.' );
     20        }
     21
     22        /**
    823         * @ticket BP4488
    924         */
    1025        public function test_thumbnail_content_images() {