@@ -1252,6 +1252,7 @@ public function prepare( $query, $args ) {
12521252 $ query = str_replace ( '"%s" ' , '%s ' , $ query ); // doublequote unquoting
12531253 $ query = preg_replace ( '|(?<!%)%f| ' , '%F ' , $ query ); // Force floats to be locale unaware
12541254 $ query = preg_replace ( '|(?<!%)%s| ' , "'%s' " , $ query ); // quote the strings, avoiding escaped strings like %%s
1255+ $ query = preg_replace ( '/%(?:%|$|([^dsF]))/ ' , '%% \\1 ' , $ query ); // escape any unescaped percents
12551256 array_walk ( $ args , array ( $ this , 'escape_by_ref ' ) );
12561257 return @vsprintf ( $ query , $ args );
12571258 }
@@ -2821,7 +2822,8 @@ protected function strip_invalid_text( $data ) {
28212822 }
28222823
28232824 if ( is_array ( $ value ['length ' ] ) ) {
2824- $ queries [ $ col ] = $ this ->prepare ( "CONVERT( LEFT( CONVERT( %s USING $ charset ), %.0f ) USING $ connection_charset ) " , $ value ['value ' ], $ value ['length ' ]['length ' ] );
2825+ $ length = sprintf ( '%.0f ' , $ value ['length ' ]['length ' ] );
2826+ $ queries [ $ col ] = $ this ->prepare ( "CONVERT( LEFT( CONVERT( %s USING $ charset ), $ length ) USING $ connection_charset ) " , $ value ['value ' ] );
28252827 } else if ( 'binary ' !== $ charset ) {
28262828 // If we don't have a length, there's no need to convert binary - it will always return the same result.
28272829 $ queries [ $ col ] = $ this ->prepare ( "CONVERT( CONVERT( %s USING $ charset ) USING $ connection_charset ) " , $ value ['value ' ] );
0 commit comments