Ticket #8210: ssh2.dash_and_shell.patch
| File ssh2.dash_and_shell.patch, 3.7 KB (added by , 17 years ago) |
|---|
-
wp-admin/includes/class-wp-filesystem-ssh2.php
217 217 return $ret; 218 218 } 219 219 220 function escape_dot($str) { 221 if (substr($str, 0, 1) != '/') # not an absolute path 222 $str = "./$str"; # assumes that "/" separates directories 223 $str = escapeshellarg($str); 224 return $str; 225 } 226 220 227 function cwd() { 221 228 $this->debug("cwd();"); 222 229 $cwd = $this->run_command($this->link, 'pwd'); … … 227 234 228 235 function chdir($dir) { 229 236 $this->debug("chdir();"); 230 return $this->run_command($this->link, 'cd ' . $dir, true);237 return $this->run_command($this->link, 'cd ' . escape_dot($dir), true); 231 238 } 232 239 233 240 function chgrp($file, $group, $recursive = false ) { … … 235 242 if ( ! $this->exists($file) ) 236 243 return false; 237 244 if ( ! $recursive || ! $this->is_dir($file) ) 238 return $this->run_command($this->link, sprintf('chgrp %o %s', $mode, $file), true);239 return $this->run_command($this->link, sprintf('chgrp -R %o %s', $mode, $file), true);245 return $this->run_command($this->link, sprintf('chgrp %o %s', $mode, escape_dot($file)), true); 246 return $this->run_command($this->link, sprintf('chgrp -R %o %s', $mode, escape_dot($file)), true); 240 247 } 241 248 242 249 function chmod($file, $mode = false, $recursive = false) { … … 248 255 if ( ! $this->exists($file) ) 249 256 return false; 250 257 if ( ! $recursive || ! $this->is_dir($file) ) 251 return $this->run_command($this->link, sprintf('chmod %o %s', $mode, $file), true);252 return $this->run_command($this->link, sprintf('chmod -R %o %s', $mode, $file), true);258 return $this->run_command($this->link, sprintf('chmod %o %s', $mode, escape_dot($file)), true); 259 return $this->run_command($this->link, sprintf('chmod -R %o %s', $mode, escape_dot($file)), true); 253 260 } 254 261 255 262 function chown($file, $owner, $recursive = false ) { … … 257 264 if ( ! $this->exists($file) ) 258 265 return false; 259 266 if ( ! $recursive || ! $this->is_dir($file) ) 260 return $this->run_command($this->link, sprintf('chown %o %s', $mode, $file), true);261 return $this->run_command($this->link, sprintf('chown -R %o %s', $mode, $file), true);267 return $this->run_command($this->link, sprintf('chown %o %s', $mode, escape_dot($file)), true); 268 return $this->run_command($this->link, sprintf('chown -R %o %s', $mode, escape_dot($file)), true); 262 269 } 263 270 264 271 function owner($file) { … … 311 318 312 319 function exists($file) { 313 320 $this->debug("exists();"); 314 return $this->run_command($this->link, sprintf('ls -lad %s', $file), true);321 return $this->run_command($this->link, sprintf('ls -lad %s', escape_dot($file)), true); 315 322 } 316 323 317 324 function is_file($file) { 318 325 $this->debug("is_file();"); 319 326 //DO NOT RELY ON dirlist()! 320 $list = $this->run_command($this->link, sprintf('ls -lad %s', $file));327 $list = $this->run_command($this->link, sprintf('ls -lad %s', escape_dot($file))); 321 328 $list = $this->parselisting($list); 322 329 if ( ! $list ) 323 330 return false; … … 328 335 function is_dir($path) { 329 336 $this->debug("is_dir();"); 330 337 //DO NOT RELY ON dirlist()! 331 $list = $this->parselisting($this->run_command($this->link, sprintf('ls -lad %s', untrailingslashit($path)))); 338 $list = $this->parselisting($this->run_command($this->link, sprintf('ls -lad %s', 339 escape_dot(untrailingslashit($path))))); 332 340 if ( ! $list ) 333 341 return false; 334 342 else … … 448 456 $limitFile = false; 449 457 } 450 458 451 $list = $this->run_command($this->link, sprintf('ls -la %s', $path));459 $list = $this->run_command($this->link, sprintf('ls -la %s', escape_dot($path))); 452 460 453 461 if ( $list === false ) 454 462 return false;