File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 115115
116116use Deployer \Host \Localhost ;
117117use Deployer \Task \Context ;
118+
118119use function Deployer \Support \rsync_rsh ;
119120
120121set ('rsync ' , [
Original file line number Diff line number Diff line change 2121use Symfony \Component \Console \Input \InputInterface ;
2222use Symfony \Component \Console \Output \OutputInterface ;
2323use Symfony \Component \Console \Question \ChoiceQuestion ;
24+
2425use function Deployer \quote ;
2526
2627/**
Original file line number Diff line number Diff line change @@ -254,13 +254,16 @@ function deployer_root(): string
254254 */
255255function rsync_rsh (array $ args ): string
256256{
257- $ rsh = 'ssh ' ;
257+ $ parts = [ 'ssh ' ] ;
258258 foreach ($ args as $ option ) {
259+ if (str_contains ($ option , "\0" )) {
260+ throw new \InvalidArgumentException ('rsync_rsh: NUL byte not allowed in ssh option ' );
261+ }
259262 if (preg_match ('/^[a-zA-Z0-9_\-=]+$/ ' , $ option )) {
260- $ rsh .= ' ' . $ option ;
263+ $ parts [] = $ option ;
261264 } else {
262- $ rsh .= ' " ' . addslashes ( $ option ) . ' " ' ;
265+ $ parts [] = " ' " . str_replace ( " ' " , " '' " , $ option ) . " ' " ;
263266 }
264267 }
265- return $ rsh ;
268+ return implode ( ' ' , $ parts ) ;
266269}
You can’t perform that action at this time.
0 commit comments