File tree 1 file changed +18
-3
lines changed
1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -26,8 +26,7 @@ public static function table($table)
26
26
if (Connect::getConn ()==null ){
27
27
self ::terminate (self ::$ response );
28
28
}
29
- //TODO sanitize the table name
30
- self ::$ table = $ table ;
29
+ self ::$ table = self ::sanitize ($ table );
31
30
32
31
return new static ;
33
32
}
@@ -393,8 +392,8 @@ protected function exec($query)
393
392
394
393
public function drop ()
395
394
{
396
- //todo validate the table name
397
395
396
+ static ::valTable ();
398
397
$ sql = /** @lang text */
399
398
"DROP TABLE " . self ::$ table ;
400
399
try {
@@ -418,4 +417,20 @@ private static function sanitize($data)
418
417
$ data = htmlspecialchars ($ data );
419
418
return $ data ;
420
419
}
420
+
421
+
422
+ /**
423
+ *Validate that the table name has been provided and is a string
424
+ */
425
+ private static function valTable (){
426
+ if (static ::$ table ==null || ! is_string (static ::$ table )){
427
+ static ::$ response ["status " ] = "error " ;
428
+ static ::$ response ["response " ] = "check the table name provided " ;
429
+ static ::$ response ["code " ]=5000 ;
430
+ return self ::terminate (static ::$ response );
431
+
432
+ }else {
433
+ static ::$ table =self ::sanitize (static ::$ table );
434
+ }
435
+ }
421
436
}
You can’t perform that action at this time.
0 commit comments