Skip to content

Commit dd46c71

Browse files
committed
Add pdo sqlite open_basedir test
1 parent 260a304 commit dd46c71

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
PDO SQLite open_basedir check
3+
--SKIPIF--
4+
<?php if (!extension_loaded('pdo_sqlite')) print 'skip not loaded'; ?>
5+
--INI--
6+
open_basedir=.
7+
--FILE--
8+
<?php
9+
chdir(__DIR__);
10+
11+
try {
12+
$db = new PDO('sqlite:../not_in_open_basedir.sqlite');
13+
} catch (Exception $e) {
14+
echo $e->getMessage() . "\n";
15+
}
16+
try {
17+
$db = new PDO('sqlite:file:../not_in_open_basedir.sqlite');
18+
} catch (Exception $e) {
19+
echo $e->getMessage() . "\n";
20+
}
21+
try {
22+
$db = new PDO('sqlite:file:../not_in_open_basedir.sqlite?mode=ro');
23+
} catch (Exception $e) {
24+
echo $e->getMessage() . "\n";
25+
}
26+
27+
?>
28+
--EXPECT--
29+
open_basedir prohibits opening ../not_in_open_basedir.sqlite
30+
open_basedir prohibits opening file:../not_in_open_basedir.sqlite
31+
open_basedir prohibits opening file:../not_in_open_basedir.sqlite?mode=ro

0 commit comments

Comments
 (0)