[wp-trac] [WordPress Trac] #24106: Simplify wp_slash()

WordPress Trac noreply at wordpress.org
Wed Feb 12 20:27:26 UTC 2014


#24106: Simplify wp_slash()
----------------------------------------+-----------------------------
 Reporter:  TobiasBg                    |       Owner:
     Type:  enhancement                 |      Status:  new
 Priority:  normal                      |   Milestone:  Future Release
Component:  Formatting                  |     Version:  3.6
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |     Focuses:
----------------------------------------+-----------------------------

Comment (by devesine):

 Replying to [comment:9 TobiasBg]:
 > devesine, I'm not sure what you mean with datatype loss here.
 `wp_slash()`/`wp_unslash()` (both the patched and the unpatched versions)
 will only work with strings and (nested) arrays of strings, which
 basically is a result of PHP's `stripslashes()` only accepting and
 returning a string.

 `wp_unslash()` uses `stripslashes_deep()` ([source:tags/3.8.1/src/wp-
 includes/formatting.php#L1529 source]) , which handles strings, arrays,
 and objects (via `get_object_vars()`), and the tests for
 `stripslashes_deep()` (and by extension `wp_unslash()`) test for its
 ability to touch objects without turning them into arrays.

 Unpatched `wp_slash()` only handles strings and arrays.  The test I
 attached uses the same logic as the existing test for
 `stripslashes_deep()`, but on the slashing rather than the unslashing side
 of things.

 `wp_unslash()` has a docblock that indicates it only works on strings or
 arrays of strings, but it is currently inaccurate.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/24106#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list