Changeset 41501 for branches/4.4
- Timestamp:
- 09/19/2017 06:14:33 PM (9 years ago)
- Location:
- branches/4.4
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
src/wp-includes/wp-db.php (modified) (2 diffs)
-
tests/phpunit/tests/db.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/4.4
-
branches/4.4/src/wp-includes/wp-db.php
r41488 r41501 1271 1271 $query = preg_replace( '|(?<!%)%f|' , '%F', $query ); // Force floats to be locale unaware 1272 1272 $query = preg_replace( '|(?<!%)%s|', "'%s'", $query ); // quote the strings, avoiding escaped strings like %%s 1273 $query = preg_replace( '/%(?:%|$|([^dsF]))/', '%%\\1', $query ); // escape any unescaped percents 1273 1274 array_walk( $args, array( $this, 'escape_by_ref' ) ); 1274 1275 return @vsprintf( $query, $args ); … … 2832 2833 2833 2834 if ( is_array( $value['length'] ) ) { 2834 $queries[ $col ] = $this->prepare( "CONVERT( LEFT( CONVERT( %s USING $charset ), %.0f ) USING $connection_charset )", $value['value'], $value['length']['length'] ); 2835 $length = sprintf( '%.0f', $value['length']['length'] ); 2836 $queries[ $col ] = $this->prepare( "CONVERT( LEFT( CONVERT( %s USING $charset ), $length ) USING $connection_charset )", $value['value'] ); 2835 2837 } else if ( 'binary' !== $charset ) { 2836 2838 // If we don't have a length, there's no need to convert binary - it will always return the same result. -
branches/4.4/tests/phpunit/tests/db.php
r41475 r41501 273 273 } 274 274 275 275 276 /** 276 277 * Test that SQL modes are set correctly … … 982 983 $this->assertNull( $row ); 983 984 } 985 986 /** 987 * 988 */ 989 function test_prepare_with_unescaped_percents() { 990 global $wpdb; 991 992 $sql = $wpdb->prepare( '%d %1$d %%% %', 1 ); 993 $this->assertEquals( '1 %1$d %% %', $sql ); 994 } 984 995 }
Note: See TracChangeset
for help on using the changeset viewer.