Bug #80358 [NEW]: PostgreSQL PDOStatement broke json after '\'
From: toxbyte at gmail dot com
Operating system:
PHP version: 7.4.12
Package: PDO PgSQL
Bug Type: Bug
Bug description:PostgreSQL PDOStatement broke json after '\'
Description:
------------
$pdo->exec($focusSql); // works correct
$pdo->prepare($focusSql)->execute(); // error
Test script:
---------------
$focusSql = <<<'SQL'
select '\', '{"x":1}'::jsonb
SQL;
$pdo->exec($focusSql) !== false and print("1 OK\n");
$pdo->prepare(<<<'SQL'
select '\\', '{"x":1}'::jsonb
SQL)->execute() and print("2 OK\n");
$pdo->prepare(<<<'SQL'
select '\', '{"x":"foo"}'::jsonb
SQL)->execute() and print("3 OK\n");
$pdo->prepare(<<<'SQL'
select '\', '{"x":1}'
SQL)->execute() and print("4 OK\n");
$pdo->prepare($focusSql)->execute() and print("5 OK\n");
Expected result:
----------------
1 OK
2 OK
3 OK
4 OK
5 OK
Actual result:
--------------
1 OK
2 OK
3 OK
4 OK
PDOException: SQLSTATE[22P02]: Invalid text representation: 7 ERROR:
invalid input syntax for type json
LINE 1: select '\', '{"x"$1}'::jsonb
^
DETAIL: Token "$" is invalid.
--
Edit bug report at https://bugs.php.net/bug.php?id=80358&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80358&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80358&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80358&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80358&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80358&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80358&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80358&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80358&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80358&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80358&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80358&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80358&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80358&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80358&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80358&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80358&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80358&r=mysqlcfg
Thread (2 messages)
- toxbyte at gmail dot com