[wp-trac] [WordPress Trac] #56119: `wp_unslash()` and `wp_slash()` do not (un)slash the same data.
WordPress Trac
noreply at wordpress.org
Fri Jul 1 03:00:34 UTC 2022
#56119: `wp_unslash()` and `wp_slash()` do not (un)slash the same data.
---------------------------+-----------------------------
Reporter: peterwilsoncc | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Formatting | Version:
Severity: normal | Keywords:
Focuses: |
---------------------------+-----------------------------
The `wp_unslash()` and `wp_slash()` functions do not do exactly the
opposite thing, ie running `$data = wp_unslash( wp_slash( $data ) )` may
modify the data.
The issue occurs with the treatment of objects, `wp_unslash()` uses
`map_deep()` and therefore accounts for objects; whereas `wp_slash()` does
not traverse objects.
{{{#!php
<?php
/**
* @ticket 56119
*/
public function test_slash_unslash_reversable() {
$expected = (object) array( 'data' => 'sl\sh' );
$actual = wp_unslash( wp_slash( clone( $expected ) ) );
$this->assertSame( $expected->data, $actual->data );
}
/**
* @ticket 56119
*/
public function test_unslash_slash_reversable() {
$expected = (object) array( 'data' => 'sl\sh' );
$actual = wp_slash( wp_unslash( clone( $expected ) ) );
$this->assertSame( $expected->data, $actual->data );
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56119>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list