[wp-trac] [WordPress Trac] #48319: About wp_date function when locale is 'ja'

WordPress Trac noreply at wordpress.org
Wed Oct 16 07:27:40 UTC 2019


#48319: About wp_date function when locale is 'ja'
--------------------------+---------------------
 Reporter:  tmatsuur      |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  5.3
Component:  Date/Time     |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+---------------------

Comment (by Rarst):

 Can confirm the regression.

 First we still ''do'' need to slash. Date localisation is double-pass,
 first WP handles the localized bits, then PHP handles the rest. But since
 we ''don't'' want PHP to interpret parts we already processed as date
 format we escape them.

 The problem is `backslashit()` has a special case of double-slashing
 numbers at start of string (I don't know why on top of my head). So in
 this case `1` turns into `\\\\\1` (two escaped slashes).

 We don't need this to happen, however since older code was more convoluted
 `\\\\1` collapsed into `\1` while being passed around (PHP handles double
 slashes as single slash whenever it processes a string) and didn't affect
 the output.

 Since new code is more streamlined `\\1` reaches the final processing and
 produces `\1` in final output.

 So we need to swap `backslashit()` use in this case with code that
 ''only'' escapes the letters (e.g. `addcslashes( $string, 'A..Za..z' )`
 part of `backslashit()` implementation). Maybe more narrowly code that
 only escapes ''valid date format'' letters.

 We could do this inline or introduce new helper function for clarity. Will
 think a bit and work on a patch.

 cc @remcotolsma who wrote the new implementation for opinion. :)

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


More information about the wp-trac mailing list