Skip to content

Commit dc552dd

Browse files
Copilotswissspidy
andcommitted
Fix escaping order for LIKE pattern in table prefix
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 7992729 commit dc552dd

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎src/DB_Command.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,8 +1315,8 @@ public function status( $_, $assoc_args ) {
13151315
// Get table prefix from wp-config.php (available after wp-config loads).
13161316
$prefix = isset( $table_prefix ) ? $table_prefix : 'wp_';
13171317

1318-
// Escape prefix for use in LIKE pattern by escaping special characters.
1319-
$escaped_prefix = addslashes( str_replace( [ '%', '_' ], [ '\\%', '\\_' ], $prefix ) );
1318+
// Escape prefix for SQL: first addslashes, then escape LIKE special characters.
1319+
$escaped_prefix = str_replace( [ '%', '_' ], [ '\\%', '\\_' ], addslashes( $prefix ) );
13201320

13211321
// Prepare command for executing queries.
13221322
$command = sprintf(

0 commit comments

Comments
 (0)