[wp-trac] [WordPress Trac] #10041: like_escape() should escape backslashes too

WordPress Trac noreply at wordpress.org
Tue Apr 1 16:59:23 UTC 2014


#10041: like_escape() should escape backslashes too
------------------------------------------------+--------------------------
 Reporter:  miau_jp                             |       Owner:
     Type:  defect (bug)                        |      Status:  reopened
 Priority:  high                                |   Milestone:  Future
Component:  Formatting                          |  Release
 Severity:  normal                              |     Version:  2.8
 Keywords:  has-patch has-unit-tests 3.2-early  |  Resolution:
                                                |     Focuses:
------------------------------------------------+--------------------------

Comment (by miqrogroove):

 Important: Convolution of slashes in MySQL:

 {{{
 SELECT 'a'
 a

 SELECT '\a'
 a

 SELECT '\\a'
 \a

 SELECT '\\\a'
 \a

 SELECT '\\\\a'
 \\a


 SELECT '%'
 %

 SELECT '\%'
 \%

 SELECT '\\%'
 \%

 SELECT '\\\%'
 \\%

 SELECT '\\\\%'
 \\%
 }}}

 The main thing to notice here is the potentially confusing result of a
 {{{LIKE '\\\%'}}} statement.  You might expect this string literal to
 represent {{{\%}}} which is a literal % at the LIKE layer.  That is not
 the case.  At the DML layer, this string literal represents {{{\\%}}}
 which is a literal slash followed by a wildcard at the LIKE layer.

 Just always keep this in mind when testing things for this ticket.  It's
 very different from string literals in PHP or even C++.

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


More information about the wp-trac mailing list