[wp-trac] [WordPress Trac] #63211: Optimize wp_slash() and Prevent Unnecessary Code Execution

WordPress Trac noreply at wordpress.org
Tue Apr 8 05:37:29 UTC 2025


#63211: Optimize wp_slash() and Prevent Unnecessary Code Execution
--------------------------+-----------------------
 Reporter:  dilipbheda    |       Owner:  audrasjb
     Type:  defect (bug)  |      Status:  accepted
 Priority:  normal        |   Milestone:  6.9
Component:  General       |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+-----------------------

Comment (by dilipbheda):

 @staurand From my point of view, we can't always predict what type of
 value a user might pass into `wp_slash()`, so it's important to structure
 the function defensively.

 The best approach is to check for arrays first using `array_map()` to
 ensure recursive processing happens before applying `addslashes()` to
 string values. This way, nested arrays are properly handled without
 skipping over any values.

 That said, the current implementation looks good to me. Let’s wait for
 feedback from others as well.

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


More information about the wp-trac mailing list