@@ -430,6 +430,27 @@ public function formatList($list)
430430 return $ ret ;
431431 }
432432
433+ public function escapeConsole ($ string )
434+ {
435+ return str_replace (
436+ array (
437+ "\x00" , "\x01" , "\x02" , "\x03" , "\x04" ,
438+ "\x05" , "\x06" , "\x07" , "\x08" , "\x09" , "\x0A" ,
439+ "\x0B" ,"\x0C" ,"\x0D" , "\x0E" , "\x0F" , "\x10" , "\x11" ,
440+ "\x12" ,"\x13" ,"\x14" ,"\x15" , "\x16" , "\x17" , "\x18" ,
441+ "\x19" ,"\x1A" ,"\x1B" ,"\x1C" ,"\x1D" , "\x1E" , "\x1F"
442+ ),
443+ array (
444+ '\x00 ' , '\x01 ' , '\x02 ' , '\x03 ' , '\x04 ' ,
445+ '\x05 ' , '\x06 ' , '\x07 ' , '\x08 ' , '\x09 ' , '\x0A ' ,
446+ '\x0B ' , '\x0C ' , '\x0D ' , '\x0E ' , '\x0F ' , '\x10 ' , '\x11 ' ,
447+ '\x12 ' , '\x13 ' , '\x14 ' , '\x15 ' , '\x16 ' , '\x17 ' , '\x18 ' ,
448+ '\x19 ' , '\x1A ' , '\x1B ' , '\x1C ' , '\x1D ' , '\x1E ' , '\x1F '
449+ ),
450+ $ string
451+ );
452+ }
453+
433454 /**
434455 * Tries to print the query and returns the result.
435456 *
@@ -455,15 +476,15 @@ public function toString($token)
455476 if ($ this ->options ['type ' ] === 'html ' ) {
456477 return '<span ' . $ format ['html ' ] . '> ' . htmlspecialchars ($ text , ENT_NOQUOTES ) . '</span> ' ;
457478 } elseif ($ this ->options ['type ' ] === 'cli ' ) {
458- return $ format ['cli ' ] . $ text ;
479+ return $ format ['cli ' ] . $ this -> escapeConsole ( $ text) ;
459480 }
460481
461482 break ;
462483 }
463484 }
464485
465486 if ($ this ->options ['type ' ] === 'cli ' ) {
466- return "\x1b[39m " . $ text ;
487+ return "\x1b[39m " . $ this -> escapeConsole ( $ text) ;
467488 } elseif ($ this ->options ['type ' ] === 'html ' ) {
468489 return htmlspecialchars ($ text , ENT_NOQUOTES );
469490 }
0 commit comments