php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57785 PDO SQLite file with non ASCII char in path
Submitted: 2007-08-14 04:20 UTC Modified: 2016-06-27 16:23 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:3 (100.0%)
From: fmate144 at gmail dot com Assigned:
Status: Verified Package: PDO SQLite
PHP Version: 5.6.10 OS: Windows
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-08-14 04:20 UTC] fmate144 at gmail dot com

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-14 05:01 UTC] wiesemann@php.net
(wrong package selection)
 [2009-02-26 11:29 UTC] iisfirewall at 126 dot com
if the path has no asc char,the pdo_sqlite3 will free work.
 [2014-02-26 11:59 UTC] wcode404 at gmail dot com
Test script:
---------------
Create folder (charset windows-1251)
C:\тест\test\

In the command line call a command
C:\тест\test\> php -r "new PDO('sqlite:test.db');"

Expected result:
----------------
Should create a database file

Actual result:
--------------
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1] unable to open database file' in Command line code:1
Stack trace:
#0 Command line code(1): PDO->__construct('sqlite:test.db')
#1 {main}
  thrown in Command line code on line 1
 [2015-06-12 12:54 UTC] cmb@php.net
-Status: Open +Status: Verified -Package: PDO_SQLITE +Package: SQLite related -Operating System: WinXP SP2 +Operating System: Windows -PHP Version: Irrelevant +PHP Version: 5.6.10
 [2015-06-12 12:54 UTC] cmb@php.net
I can confirm this issue for CP-1252 with the reproduce script
given by wcode404 (thanks!).

When the relative path ("test.db") is expanded to a an absolute
path by expand_path[1], the path is not UTF-8 encoded, but later
sqlite3_open[2] is called, which expects an UTF-8 encoded
filename. Using sqlite3_open16 instead would work for me, but that's
likely not an option for portability reasons[3]:

| The default encoding will be UTF-8 for databases created using
| sqlite3_open() or sqlite3_open_v2(). The default encoding for
| databases created using sqlite3_open16() will be UTF-16 in the
| native byte order.

The same problem affects the SQLite3 extension, too.

[1] <https://github.com/php/php-src/blob/php-5.6.10/ext/pdo_sqlite/sqlite_driver.c#L764>
[2] <https://github.com/php/php-src/blob/php-5.6.10/ext/pdo_sqlite/sqlite_driver.c#L832>
[3] <https://www.sqlite.org/c3ref/open.html>
 [2016-06-27 16:23 UTC] cmb@php.net
-Package: SQLite related +Package: PDO SQLite
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Fri Apr 28 02:01:36 2017 UTC