Skip to content

PdoDriver: fix escapeBinary() for SQLite binary containing NUL bytes - #475

Open
zeleznypa wants to merge 1 commit into
dg:v5.1from
zeleznypa:pdo-sqlite-escape-binary
Open

PdoDriver: fix escapeBinary() for SQLite binary containing NUL bytes#475
zeleznypa wants to merge 1 commit into
dg:v5.1from
zeleznypa:pdo-sqlite-escape-binary

Conversation

@zeleznypa

Copy link
Copy Markdown

PdoDriver::escapeBinary() has no sqlite branch and falls through to PDO::quote($value, PDO::PARAM_LOB). On PHP 8.5, PDO::quote() returns false for values containing NUL bytes, which surfaces as a TypeError because the method is typed : string. This mirrors the native SqliteDriver::escapeBinary(), which already uses a hex literal X'...'.

Changes:

  • Add the 'sqlite' branch to PdoDriver::escapeBinary() (mirrors SqliteDriver).
  • Add tests/dibi/PdoDriver.escapeBinary.phpt.

Targeted at v5.1 as it affects the current stable release. PdoDriver::escapeText() has the same structure for SQLite, but binary data should go through %bin / escapeBinary() — happy to extend if you prefer.

Note: the red Tests / Static Analysis checks are pre-existing on v5.1 and unrelated to this change — tests/types/dibi-types.phpt and PHPStan fail to bootstrap (ServiceCreationException, a phpstan/phpstannette/phpstan-rules incompatibility). Coding Style and the new PdoDriver.escapeBinary.phpt pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant