1--TEST--
2PDO_sqlite: Testing filenames with open_basedir
3--EXTENSIONS--
4pdo_sqlite
5--INI--
6open_basedir=.
7--FILE--
8<?php
9
10// create in basedir
11$filename = 'pdo_sqlite_filename.db';
12
13$db = new PDO('sqlite:' . $filename);
14
15var_dump($db->exec('CREATE TABLE test_sqlite_open_basedir (id INT);'));
16
17// create outside basedir
18$filename = '..' . DIRECTORY_SEPARATOR . 'pdo_sqlite_filename.db';
19
20new PDO('sqlite:' . $filename);
21?>
22
23--CLEAN--
24<?php
25$filenames = [
26    'pdo_sqlite_filename.db',
27    '..' . DIRECTORY_SEPARATOR . 'pdo_sqlite_filename.db',
28];
29foreach ($filenames as $filename) {
30    if (file_exists($filename)) {
31        unlink($filename);
32    }
33}
34?>
35--EXPECTF--
36int(0)
37
38Fatal error: Uncaught PDOException: PDO::__construct(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s) in %s:%d
39Stack trace:
40%s
41#1 {main}
42
43Next PDOException: open_basedir prohibits opening %s in %s:%d
44Stack trace:
45%s
46#1 {main}
47  thrown in %s
48