diff --git a/composer.json b/composer.json index f8b5124..9642264 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,6 @@ "rize/uri-template": "^0.4.1 || ^0.3" }, "require-dev": { - "clue/caret-notation": "^0.2", "clue/tar-react": "^0.2", "phpunit/phpunit": "^9.6 || ^8.5 || ^5.7 || ^4.8.36", "react/async": "^4.3 || ^3 || ^2" diff --git a/examples/archive.php b/examples/archive.php index 754c6b3..6e09e9a 100644 --- a/examples/archive.php +++ b/examples/archive.php @@ -16,14 +16,12 @@ $tar = new Clue\React\Tar\Decoder(); -// use caret notation for any control characters except \t, \r and \n -$caret = new Clue\CaretNotation\Encoder("\t\r\n"); - -$tar->on('entry', function ($header, React\Stream\ReadableStreamInterface $file) use ($caret) { +$tar->on('entry', function ($header, React\Stream\ReadableStreamInterface $file) { // write each entry to the console output - echo '########## ' . $caret->encode($header['filename']) . ' ##########' . PHP_EOL; - $file->on('data', function ($chunk) use ($caret) { - echo $caret->encode($chunk); + echo '########## ' . $header['filename'] . ' ##########' . PHP_EOL; + $file->on('data', function ($chunk) { + // escape control characters except \t, \r and \n + echo addcslashes($chunk, "\x00..\x08\x0b\x0c\x0e..\x1f\x7f"); }); }); diff --git a/examples/attach-stream.php b/examples/attach-stream.php index 5a9f2d5..f795f4a 100644 --- a/examples/attach-stream.php +++ b/examples/attach-stream.php @@ -13,13 +13,11 @@ $client = new Clue\React\Docker\Client(); -// use caret notation for any control characters except \t, \r and \n -$caret = new Clue\CaretNotation\Encoder("\t\r\n"); - $stream = $client->containerAttachStream($container, true, true); -$stream->on('data', function ($data) use ($caret) { - echo $caret->encode($data); +$stream->on('data', function ($data) { + // escape control characters except \t, \r and \n + echo addcslashes($data, "\x00..\x08\x0b\x0c\x0e..\x1f\x7f"); }); $stream->on('error', function (Exception $e) { diff --git a/examples/logs-stream.php b/examples/logs-stream.php index 3aae06b..936ada2 100644 --- a/examples/logs-stream.php +++ b/examples/logs-stream.php @@ -10,13 +10,11 @@ $client = new Clue\React\Docker\Client(); -// use caret notation for any control characters except \t, \r and \n -$caret = new Clue\CaretNotation\Encoder("\t\r\n"); - $stream = $client->containerLogsStream($container, true, true, true, 0, false, 100); -$stream->on('data', function ($data) use ($caret) { - echo $caret->encode($data); +$stream->on('data', function ($data) { + // escape control characters except \t, \r and \n + echo addcslashes($data, "\x00..\x08\x0b\x0c\x0e..\x1f\x7f"); }); $stream->on('error', function (Exception $e) { diff --git a/examples/logs.php b/examples/logs.php index 3ac3844..b0645b8 100644 --- a/examples/logs.php +++ b/examples/logs.php @@ -7,7 +7,6 @@ // $ php examples/logs.php foo // $ docker rm foo -use Clue\CaretNotation\Encoder; use Clue\React\Docker\Client; require __DIR__ . '/../vendor/autoload.php'; @@ -22,8 +21,7 @@ function ($logs) { echo 'Received the following logs:' . PHP_EOL; // escape control characters (dumping logs of vi/nano etc.) - $caret = new Clue\CaretNotation\Encoder("\t\r\n"); - echo $caret->encode($logs); + echo addcslashes($logs, "\x00..\x08\x0b\x0c\x0e..\x1f\x7f"); }, function (Exception $e) use ($container) { echo <<