Repository navigation
Highlights
Security fixes
matchPattern(): Escape the LIKE wildcards before the string, not after. The old order escaped the escape characters added for the string: on mysqli a pattern containing'ended the string literal, and on pgsql a literal%or_acted as a wildcard (#18)decimal/float: These values are written into the query unquoted, so a value that is not a valid number (e.g.1--) now returnsMDB2_ERROR_INVALID_NUMBER(#18)- NUL bytes: pgsql and sqlite3 return
MDB2_ERROR_INVALIDfor a string containing a NUL byte instead of silently truncating it at that byte (#18) - LOB values: A
clob/blobvalue that looks like a URL is only opened whenlob_allow_url_includeis enabled (the default is disabled). Before, prepared statements on pgsql opened it whatever the option said (#18) loadClass()/loadFile(): Only accept[A-Za-z0-9_](and/forloadFile()), since the name (e.g. thephptypeof a DSN) becomes a file path (#18)- pgsql
setLimit()with UPDATE / DELETE: Find theWHEREclause outside string literals, identifiers, comments and parentheses, and match the rows by(tableoid, ctid). A quoted value containingwhere ... --could otherwise widen the statement to every row, and rows of inherited tables could be updated or deleted by mistake (#19, #21)
Bug fixes
- pgsql: Map
timetz(TIME WITH TIME ZONE) to the MDB2timetype (#17, #20) - pgsql:
setLimit()with UPDATE / DELETE no longer throws aTypeErroron PHP 8, and no longer drops theSETclause on PHP 7 (#19, #21) setLimit(): Ignore string literals, delimited identifiers and comments when checking whether the query already has aLIMITclause, so a value such as'LIMIT 1'no longer stops the limit from being applied (#18)- Multibyte charsets: With Shift_JIS, CP932, GBK, Big5 or GB18030 connections, the query is read character by character, so a second byte of 0x5C is not taken for a backslash (#22)
Behavior changes
These inputs used to be accepted and now return an MDB2_Error:
| Input | Before | After |
|---|---|---|
quote('1-1', 'decimal'), quote('abc', 'float'), ... |
unquoted 1-1, empty string |
MDB2_ERROR_INVALID_NUMBER |
a string with a NUL byte on pgsql / sqlite3 (including sqlite3 blob) |
truncated at the NUL byte | MDB2_ERROR_INVALID |
a clob / blob URL that cannot be opened, with lob_allow_url_include enabled |
empty value | MDB2_ERROR_NOT_FOUND |
phptype with characters other than [A-Za-z0-9_] |
include attempted | MDB2_ERROR_NOT_FOUND |
query(), exec() and standaloneQuery() now connect before rewriting the query for setLimit(), so a connection error is returned before anything else is done.
Known issues
- pgsql
setLimit()with UPDATE / DELETE: A statement that cannot be parsed (e.g. a quoted table name orDELETE FROM ONLY t) is still run without the limit. - PHP 7.4 and Big5 on mysqli: The mysqlnd of PHP 7.4 does not take
0xA1 0x5Cfor one Big5 character, somysqli_real_escape_string()itself produces a string the server reads differently. This is a PHP issue and also affects 2.5.2. Use a different charset (e.g. utf8mb4) or a newer PHP. - The untested drivers (
mysql,mssql,oci8, ...) do not get these fixes.
What's Changed
- fix: harden quoting and LOB handling by @nanasess in #18
- fix: map PostgreSQL timetz to the MDB2 time type by @nanasess in #20
- fix: make setLimit() work with UPDATE / DELETE on pgsql by @nanasess in #21
- fix: read literals in the multibyte charset of the connection by @nanasess in #22
Full Changelog: 2.5.2...2.6.0