mirror of
https://github.com/filegator/filegator.git
synced 2025-08-20 07:01:30 +02:00
Fix for UTF8 filename issues (#12)
This commit is contained in:
@@ -156,7 +156,21 @@ class FilesTest extends TestCase
|
||||
touch(TEST_REPOSITORY.'/john/john.txt', $this->timestamp);
|
||||
|
||||
$path_encoded = base64_encode('john.txt');
|
||||
$this->sendRequest('GET', '/download/'.$path_encoded);
|
||||
$this->sendRequest('GET', '/download&path='.$path_encoded);
|
||||
|
||||
$this->assertOk();
|
||||
}
|
||||
|
||||
public function testDownloadUTF8File()
|
||||
{
|
||||
$username = 'john@example.com';
|
||||
$this->signIn($username, 'john123');
|
||||
|
||||
mkdir(TEST_REPOSITORY.'/john');
|
||||
touch(TEST_REPOSITORY.'/john/ąčęėįšųū.txt', $this->timestamp);
|
||||
|
||||
$path_encoded = base64_encode('/ąčęėįšųū.txt');
|
||||
$this->sendRequest('GET', '/download&path='.$path_encoded);
|
||||
|
||||
$this->assertOk();
|
||||
}
|
||||
@@ -166,7 +180,7 @@ class FilesTest extends TestCase
|
||||
touch(TEST_REPOSITORY.'/test.txt', $this->timestamp);
|
||||
|
||||
$path_encoded = base64_encode('test.txt');
|
||||
$this->sendRequest('GET', '/download/'.$path_encoded);
|
||||
$this->sendRequest('GET', '/download&path='.$path_encoded);
|
||||
|
||||
$this->assertStatus(404);
|
||||
}
|
||||
@@ -181,7 +195,7 @@ class FilesTest extends TestCase
|
||||
touch(TEST_REPOSITORY.'/jane/jane.txt', $this->timestamp);
|
||||
|
||||
$path_encoded = base64_encode('jane.txt');
|
||||
$this->sendRequest('GET', '/download/'.$path_encoded);
|
||||
$this->sendRequest('GET', '/download&path='.$path_encoded);
|
||||
|
||||
$this->assertStatus(404);
|
||||
}
|
||||
@@ -192,7 +206,7 @@ class FilesTest extends TestCase
|
||||
$this->signIn($username, 'john123');
|
||||
|
||||
$path_encoded = base64_encode('missing.txt');
|
||||
$this->sendRequest('GET', '/download/'.$path_encoded);
|
||||
$this->sendRequest('GET', '/download&path='.$path_encoded);
|
||||
|
||||
$this->assertStatus(302);
|
||||
}
|
||||
|
@@ -317,4 +317,43 @@ class UploadTest extends TestCase
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function testFileUploadWithUTF8()
|
||||
{
|
||||
$this->signIn('john@example.com', 'john123');
|
||||
|
||||
$files = ['file' => new UploadedFile(TEST_FILE, 'ąčęėįšųū.txt', 'text/plain', null, true)];
|
||||
|
||||
$data = [
|
||||
'resumableChunkNumber' => 1,
|
||||
'resumableChunkSize' => 1048576,
|
||||
'resumableCurrentChunkSize' => 0.5 * 1024 * 1024,
|
||||
'resumableTotalChunks' => 1,
|
||||
'resumableTotalSize' => 0.5 * 1024 * 1024,
|
||||
'resumableType' => 'text/plain',
|
||||
'resumableIdentifier' => 'CHUNKS-SIMPLE-TEST',
|
||||
'resumableFilename' => "ąčęėįšųū.txt",
|
||||
'resumableRelativePath' => '/',
|
||||
];
|
||||
|
||||
$this->sendRequest('POST', '/upload', $data, $files);
|
||||
|
||||
$this->assertOk();
|
||||
|
||||
$this->sendRequest('POST', '/getdir', [
|
||||
'dir' => '/',
|
||||
]);
|
||||
|
||||
$this->assertResponseJsonHas([
|
||||
'data' => [
|
||||
'files' => [
|
||||
0 => [
|
||||
'type' => 'file',
|
||||
'path' => '/ąčęėįšųū.txt',
|
||||
'name' => 'ąčęėįšųū.txt',
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user