diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Utils/Formatter.php | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/Utils/Formatter.php b/src/Utils/Formatter.php index 9804580..41b5094 100644 --- a/src/Utils/Formatter.php +++ b/src/Utils/Formatter.php @@ -430,6 +430,27 @@ class Formatter return $ret; } + public function escapeConsole($string) + { + return str_replace( + array( + "\x00", "\x01", "\x02", "\x03", "\x04", + "\x05", "\x06", "\x07", "\x08", "\x09", "\x0A", + "\x0B","\x0C","\x0D", "\x0E", "\x0F", "\x10", "\x11", + "\x12","\x13","\x14","\x15", "\x16", "\x17", "\x18", + "\x19","\x1A","\x1B","\x1C","\x1D", "\x1E", "\x1F" + ), + array( + '\x00', '\x01', '\x02', '\x03', '\x04', + '\x05', '\x06', '\x07', '\x08', '\x09', '\x0A', + '\x0B', '\x0C', '\x0D', '\x0E', '\x0F', '\x10', '\x11', + '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18', + '\x19', '\x1A', '\x1B', '\x1C', '\x1D', '\x1E', '\x1F' + ), + $string + ); + } + /** * Tries to print the query and returns the result. * @@ -455,7 +476,7 @@ class Formatter if ($this->options['type'] === 'html') { return '<span ' . $format['html'] . '>' . htmlspecialchars($text, ENT_NOQUOTES) . '</span>'; } elseif ($this->options['type'] === 'cli') { - return $format['cli'] . $text; + return $format['cli'] . $this->escapeConsole($text); } break; @@ -463,7 +484,7 @@ class Formatter } if ($this->options['type'] === 'cli') { - return "\x1b[39m" . $text; + return "\x1b[39m" . $this->escapeConsole($text); } elseif ($this->options['type'] === 'html') { return htmlspecialchars($text, ENT_NOQUOTES); } |