File tree Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -89,18 +89,22 @@ public function parse_statements( $sql_file_path ) {
8989 for ( $ i = 0 ; $ i < $ strlen ; $ i ++ ) {
9090 $ ch = $ line [ $ i ];
9191
92- // Count preceding backslashes.
93- $ slashes = 0 ;
94- while ( $ slashes < $ i && '\\' === $ line [ $ i - $ slashes - 1 ] ) {
95- ++$ slashes ;
96- }
92+ // Handle escape sequences in single and double quoted strings.
93+ // TODO: Support NO_BACKSLASH_ESCAPES SQL mode.
94+ if ( "' " === $ ch || '" ' === $ ch ) {
95+ // Count preceding backslashes.
96+ $ slashes = 0 ;
97+ while ( $ slashes < $ i && '\\' === $ line [ $ i - $ slashes - 1 ] ) {
98+ ++$ slashes ;
99+ }
97100
98- // Handle escaped characters.
99- // A characters is escaped only when the number of preceding backslashes
100- // is odd - "\" is an escape sequence, "\\" is an escaped backslash.
101- if ( 1 === $ slashes % 2 ) {
102- $ buffer .= $ ch ;
103- continue ;
101+ // Handle escaped characters.
102+ // A characters is escaped only when the number of preceding backslashes
103+ // is odd - "\" is an escape sequence, "\\" is an escaped backslash.
104+ if ( 1 === $ slashes % 2 ) {
105+ $ buffer .= $ ch ;
106+ continue ;
107+ }
104108 }
105109
106110 // Handle comments.
You can’t perform that action at this time.
0 commit comments