Bug #57785 [Opn->Ver]: PDO SQLite file with non ASCII char in path

From: Date: Fri, 12 Jun 2015 12:54:04 +0000
Subject: Bug #57785 [Opn->Ver]: PDO SQLite file with non ASCII char in path
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193356@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=57785&edit=1

 ID:                 57785
 Updated by:         cmb@php.net
 Reported by:        fmate144 at gmail dot com
 Summary:            PDO SQLite file with non ASCII char in path
-Status:             Open
+Status:             Verified
 Type:               Bug
-Package:            PDO_SQLITE
+Package:            SQLite related
-Operating System:   WinXP SP2
+Operating System:   Windows
-PHP Version:        Irrelevant
+PHP Version:        5.6.10
 Block user comment: N
 Private report:     N

 New Comment:

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>


Previous Comments:
------------------------------------------------------------------------
[2014-02-26 11:59:37] 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

------------------------------------------------------------------------
[2009-02-26 11:29:51] iisfirewall at 126 dot com

if the path has no asc char,the pdo_sqlite3 will free work.

------------------------------------------------------------------------
[2007-08-14 05:01:08] wiesemann@php.net

(wrong package selection)

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

Description:
------------
I have a simple sqlite database file. If in its path is non ASCII characters, the PDO can not open
it!

Reproduce code:
---------------
<?php
// In c:\xéx\test.php
// Exception: unable to open database file
$db = new PDO('sqlite:test.db3');
// Work good!
$db = sqlite_open('test.db3', 0666, $sqliteerror);

// In c:\xex\test.php both work good.
?>

Expected result:
----------------
unable to open database file



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=57785&edit=1


Thread (1 message)

  • cmb@php.net
  • Unknown Message
    • cmb@php.net
« previous php.bugs (#193356) next »