mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 09:14:06 +02:00
Fix passing of locale
This commit is contained in:
parent
7353a25b99
commit
719dcf6ca9
3 changed files with 17 additions and 5 deletions
|
|
@ -9,6 +9,9 @@
|
|||
namespace SMB;
|
||||
|
||||
class Connection {
|
||||
|
||||
const DELIMITER = 'smb:';
|
||||
|
||||
/**
|
||||
* @var resource[] $pipes
|
||||
*
|
||||
|
|
@ -26,12 +29,12 @@ class Connection {
|
|||
public function __construct($command) {
|
||||
$descriptorSpec = array(
|
||||
0 => array("pipe", "r"),
|
||||
1 => array("pipe", "w"),
|
||||
1 => array("pipe", "w")
|
||||
);
|
||||
putenv('LC_ALL=' . Server::LOCALE);
|
||||
setlocale(LC_ALL, Server::LOCALE);
|
||||
$this->process = proc_open($command, $descriptorSpec, $this->pipes, null, array(
|
||||
'CLI_FORCE_INTERACTIVE' => 'y' // Needed or the prompt isn't displayed!!
|
||||
'CLI_FORCE_INTERACTIVE' => 'y', // Needed or the prompt isn't displayed!!
|
||||
'LC_ALL' => Server::LOCALE
|
||||
));
|
||||
if (!is_resource($this->process)) {
|
||||
throw new ConnectionError();
|
||||
|
|
@ -58,7 +61,8 @@ class Connection {
|
|||
fgets($this->pipes[1]); //first line is prompt
|
||||
$output = array();
|
||||
$line = fgets($this->pipes[1]);
|
||||
while (substr($line, 0, 4) !== 'smb:') { //next prompt functions as delimiter
|
||||
$length = strlen(self::DELIMITER);
|
||||
while (substr($line, 0, $length) !== self::DELIMITER) { //next prompt functions as delimiter
|
||||
$output[] .= $line;
|
||||
$line = fgets($this->pipes[1]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,13 @@ class Share {
|
|||
$this->connection->write($this->server->getPassword());
|
||||
}
|
||||
|
||||
public function connect() {
|
||||
$command = Server::CLIENT . ' -U ' . escapeshellarg($this->server->getUser()) .
|
||||
' //' . $this->server->getHost() . '/' . $this->name;
|
||||
$this->connection = new Connection($command);
|
||||
$this->connection->write($this->server->getPassword());
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class Test extends PHPUnit_Framework_TestCase {
|
|||
|
||||
public function testEscaping() {
|
||||
// / ? < > \ : * | ” are illegal characters in path on windows, no use trying to get them working
|
||||
$names = array('simple', 'with spaces', "single'quote'", '$as#d');
|
||||
$names = array('simple', 'with spaces', "single'quote'", '$as#d', '€', '££Ö€ßœĚęĘĞĜΣΥΦΩΫΫ');
|
||||
|
||||
$text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua';
|
||||
$tmpFile1 = tempnam('/tmp', 'smb_test_');
|
||||
|
|
@ -95,6 +95,7 @@ class Test extends PHPUnit_Framework_TestCase {
|
|||
|
||||
foreach ($names as $name) {
|
||||
$this->share->mkdir($this->root . '/' . $name);
|
||||
$this->share->connect();
|
||||
$dir = $this->share->dir($this->root);
|
||||
$this->assertArrayHasKey($name, $dir);
|
||||
$this->assertEquals('dir', $dir[$name]['type']);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue