Make WordPress Core

Changeset 65188


Ignore:
Timestamp:
11/02/2026 03:49:03 PM (18 hours ago)
Author:
lancewillett
Message:

Tests: Cover array preservation in string-only unslashing.

Verify that stripslashes_from_strings_only() leaves an array containing a slashed string unchanged. The existing stripslashes_deep() tests exercise recursive processing instead of this direct-input contract.

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/15325

Props devmuhib, huzaifaalmesbah.
See #65819.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/formatting/stripslashesDeep.php

    r64066 r65188  
    66 *
    77 * @covers ::stripslashes_deep
     8 * @covers ::stripslashes_from_strings_only
    89 */
    910class Tests_Formatting_StripslashesDeep extends WP_UnitTestCase {
    … …  
    5657                $this->assertSame( $txt, stripslashes_deep( "I can\'t see, isn\\\\\'t that it?" ) );
    5758        }
     59
     60        /**
     61         * Tests that stripslashes_from_strings_only() does not strip slashes from array elements.
     62         *
     63         * Unlike stripslashes_deep(), stripslashes_from_strings_only() does not recurse into arrays.
     64         *
     65         * @ticket 65819
     66         */
     67        public function test_stripslashes_from_strings_only_does_not_strip_array() {
     68                $slashed_array = array( "I can\'t see", 'b' );
     69
     70                $this->assertSame( $slashed_array, stripslashes_from_strings_only( $slashed_array ) );
     71        }
    5872}
Note: See TracChangeset for help on using the changeset viewer.