File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121 "clue/json-stream" : " ~0.1.0"
2222 },
2323 "require-dev" : {
24- "clue/tar-react" : " ~0.1.0"
24+ "clue/tar-react" : " ~0.1.0" ,
25+ "clue/caret-notation" : " ~0.2.0"
2526 }
2627}
Original file line number Diff line number Diff line change 99use Clue \React \Docker \Factory ;
1010use Clue \React \Tar \Decoder ;
1111use React \Stream \ReadableStreamInterface ;
12+ use Clue \CaretNotation \Encoder ;
1213
1314$ container = isset ($ argv [1 ]) ? $ argv [1 ] : 'asd ' ;
1415$ file = isset ($ argv [2 ]) ? $ argv [2 ] : '/etc/passwd ' ;
2324
2425$ tar = new Decoder ();
2526
26- $ tar ->on ('entry ' , function ($ header , ReadableStreamInterface $ file ) {
27+ // use caret notation for any control characters expect \t, \r and \n
28+ $ caret = new Encoder ("\t\r\n" );
29+
30+ $ tar ->on ('entry ' , function ($ header , ReadableStreamInterface $ file ) use ($ caret ) {
2731 // write each entry to the console output
28- echo '########## ' . $ header ['filename ' ] . ' ########## ' . PHP_EOL ;
29- $ file ->on ('data ' , function ($ chunk ) {
30- echo $ chunk ;
32+ echo '########## ' . $ caret -> encode ( $ header ['filename ' ]) . ' ########## ' . PHP_EOL ;
33+ $ file ->on ('data ' , function ($ chunk ) use ( $ caret ) {
34+ echo $ caret -> encode ( $ chunk) ;
3135 });
3236});
3337
You can’t perform that action at this time.
0 commit comments