[wp-trac] [WordPress Trac] #32279: Creating new posts/terms with non-latin characters is broken for tables with cp1251 collation in 4.1.5

WordPress Trac noreply at wordpress.org
Mon Jun 22 05:42:03 UTC 2015


#32279: Creating new posts/terms with non-latin characters is broken for tables
with cp1251 collation in 4.1.5
--------------------------+-----------------------
 Reporter:  vloo          |       Owner:
     Type:  defect (bug)  |      Status:  reopened
 Priority:  high          |   Milestone:  4.2.3
Component:  Database      |     Version:  4.1.5
 Severity:  critical      |  Resolution:
 Keywords:                |     Focuses:
--------------------------+-----------------------
Changes (by dd32):

 * status:  closed => reopened
 * resolution:  duplicate =>
 * milestone:   => 4.2.3


Comment:

 I'm re-opening this as it seems like a different case than #32165 from
 what I can understand.

 The issue at play here, from what I can see, is initially that the
 following query will '''always''' fail, as `strip_text_from_query()` will
 return `''`:
 {{{
 INSERT INTO table_with_cp1251_charset( `a` ) VALUES( 'safe data' )
 }}}

 The reason is that ultimately it performs this query:
 {{{
 LEFT( CONVERT( 'INSERT INTO table_with_cp1251_charset( `a` ) VALUES(
 \'safe data\' )' USING cp1251 ), 0 )
 }}}

 The `LEFT( %s, 0 )` means it'll always fail, the 0 comes from the fact
 that `strip_invalid_text()` currently requires the `length` field be
 present when testing non-utf8/utf8mb4/latin1 strings, and
 `strip_invalid_text_from_query()` never passes that field.

 Attached in [attachment:32279.diff 32279.diff] is a unit test that
 demonstrates that, and a fix that passes the unit-test, but one that I'm
 not confident in - I'm struggling to find an example query that should
 fail.
 As I understand it, the fix should be OK since the idea is that the
 `CONVERT()` query should fail, or return a different length of data, which
 causes the failure to get raised higher up in the chain.

 I don't think this fixes all of the issues, I suspect #32165 will still
 kick in, but this allows the install & term creation to work again..

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


More information about the wp-trac mailing list