Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions res/sqlite-worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@
'id' => $data->id,
'error' => array('message' => $e->getMessage())
));
} catch (Error $e) {
$out->write(array(
'id' => $data->id,
'error' => array('message' => $e->getMessage())
));
}
} elseif ($data->method === 'open' && \count($data->params) === 2 && \is_string($data->params[0]) && \is_int($data->params[1])) {
// open database with two parameters: $filename, $flags
Expand All @@ -108,6 +113,11 @@
'id' => $data->id,
'error' => array('message' => $e->getMessage())
));
} catch (Error $e) {
$out->write(array(
'id' => $data->id,
'error' => array('message' => $e->getMessage())
));
}
} elseif ($data->method === 'exec' && $db !== null && \count($data->params) === 1 && \is_string($data->params[0])) {
// execute statement and suppress PHP warnings
Expand Down
23 changes: 23 additions & 0 deletions tests/FunctionalDatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,29 @@ public function testOpenInvalidPathRejects($flag)
$loop->run();
}

/**
* @dataProvider provideSocketFlags
* @param bool $flag
*/
public function testOpenInvalidPathWithNullByteRejects($flag)
{
$loop = \React\EventLoop\Factory::create();
$factory = new Factory($loop);

$ref = new \ReflectionProperty($factory, 'useSocket');
$ref->setAccessible(true);
$ref->setValue($factory, $flag);

$promise = $factory->open("test\0.db");

$promise->then(
null,
$this->expectCallableOnceWith($this->isInstanceOf('RuntimeException'))
);

$loop->run();
}

/**
* @dataProvider provideSocketFlags
* @param bool $flag
Expand Down