Skip to content

Commit adc0d52

Browse files
Copilotswissspidy
andauthored
Fix split_sql_statements() to handle backslash-escaped quotes inside SQL strings
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent f85364e commit adc0d52

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎src/DB_Command.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2645,6 +2645,15 @@ private function split_sql_statements( $sql ) {
26452645
continue;
26462646
}
26472647

2648+
// Handle backslash escaping inside quoted strings (e.g. \' or \").
2649+
if ( '\\' === $char && ( $in_single_quote || $in_double_quote ) ) {
2650+
$current .= $char;
2651+
if ( $i + 1 < $length ) {
2652+
$current .= $sql[ ++$i ];
2653+
}
2654+
continue;
2655+
}
2656+
26482657
if ( "'" === $char && ! $in_double_quote ) {
26492658
$in_single_quote = ! $in_single_quote;
26502659
} elseif ( '"' === $char && ! $in_single_quote ) {

0 commit comments

Comments
 (0)