File tree 1 file changed +14
-2
lines changed
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -273,8 +273,11 @@ pub(crate) fn check(
273
273
) -> Option < Output > {
274
274
// INSERT don't need MySQL federated check. We assume the query doesn't contain
275
275
// federated or driver setup command if it starts with a 'INSERT' statement.
276
- if query. len ( ) > 6 && query[ ..6 ] . eq_ignore_ascii_case ( "INSERT" ) {
277
- return None ;
276
+ let the_6th_index = query. char_indices ( ) . nth ( 6 ) . map ( |( i, _) | i) ;
277
+ if let Some ( index) = the_6th_index {
278
+ if query[ ..index] . eq_ignore_ascii_case ( "INSERT" ) {
279
+ return None ;
280
+ }
278
281
}
279
282
280
283
// First to check the query is like "select @@variables".
@@ -295,6 +298,15 @@ mod test {
295
298
296
299
use super :: * ;
297
300
301
+ #[ test]
302
+ fn test_check_abnormal ( ) {
303
+ let session = Arc :: new ( Session :: new ( None , Channel :: Mysql , Default :: default ( ) ) ) ;
304
+ let query = "🫣一点不正常的东西🫣" ;
305
+ let output = check ( query, QueryContext :: arc ( ) , session. clone ( ) ) ;
306
+
307
+ assert ! ( output. is_none( ) ) ;
308
+ }
309
+
298
310
#[ test]
299
311
fn test_check ( ) {
300
312
let session = Arc :: new ( Session :: new ( None , Channel :: Mysql , Default :: default ( ) ) ) ;
You can’t perform that action at this time.
0 commit comments