v1.6.9
This commit is contained in:
parent
1ff471299e
commit
7379505d20
18 changed files with 912 additions and 139 deletions
21
vendor/composer/installed.json
vendored
21
vendor/composer/installed.json
vendored
|
|
@ -113,30 +113,31 @@
|
|||
},
|
||||
{
|
||||
"name": "maxmind-db/reader",
|
||||
"version": "v1.13.1",
|
||||
"version_normalized": "1.13.1.0",
|
||||
"version": "v1.14.0",
|
||||
"version_normalized": "1.14.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/maxmind/MaxMind-DB-Reader-php.git",
|
||||
"reference": "2194f58d0f024ce923e685cdf92af3daf9951908"
|
||||
"reference": "f3c92f68b3bec42a9aa780368399e03dc6b91e89"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/maxmind/MaxMind-DB-Reader-php/zipball/2194f58d0f024ce923e685cdf92af3daf9951908",
|
||||
"reference": "2194f58d0f024ce923e685cdf92af3daf9951908",
|
||||
"url": "https://api.github.com/repos/maxmind/MaxMind-DB-Reader-php/zipball/f3c92f68b3bec42a9aa780368399e03dc6b91e89",
|
||||
"reference": "f3c92f68b3bec42a9aa780368399e03dc6b91e89",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2"
|
||||
},
|
||||
"conflict": {
|
||||
"ext-maxminddb": "<1.11.1 || >=2.0.0"
|
||||
"ext-maxminddb": "<1.14.0 || >=2.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "3.*",
|
||||
"phpstan/phpstan": "*",
|
||||
"phpunit/phpunit": ">=8.0.0,<10.0.0",
|
||||
"squizlabs/php_codesniffer": "4.*"
|
||||
"squizlabs/php_codesniffer": "4.*",
|
||||
"symfony/polyfill-php80": "^1.33"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-bcmath": "bcmath or gmp is required for decoding larger integers with the pure PHP decoder",
|
||||
|
|
@ -144,7 +145,7 @@
|
|||
"ext-maxminddb": "A C-based database decoder that provides significantly faster lookups",
|
||||
"maxmind-db/reader-ext": "C extension for significantly faster IP lookups (install via PIE: pie install maxmind-db/reader-ext)"
|
||||
},
|
||||
"time": "2025-11-21T22:24:26+00:00",
|
||||
"time": "2026-09-10T22:02:38+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
|
|
@ -160,7 +161,7 @@
|
|||
{
|
||||
"name": "Gregory J. Oschwald",
|
||||
"email": "goschwald@maxmind.com",
|
||||
"homepage": "https://www.maxmind.com/"
|
||||
"homepage": "https://www.maxmind.com/en/home"
|
||||
}
|
||||
],
|
||||
"description": "MaxMind DB Reader API",
|
||||
|
|
@ -174,7 +175,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/maxmind/MaxMind-DB-Reader-php/issues",
|
||||
"source": "https://github.com/maxmind/MaxMind-DB-Reader-php/tree/v1.13.1"
|
||||
"source": "https://github.com/maxmind/MaxMind-DB-Reader-php/tree/v1.14.0"
|
||||
},
|
||||
"install-path": "../maxmind-db/reader"
|
||||
}
|
||||
|
|
|
|||
10
vendor/composer/installed.php
vendored
10
vendor/composer/installed.php
vendored
|
|
@ -3,7 +3,7 @@
|
|||
'name' => 'robotstxt/robotstxt-2fa',
|
||||
'pretty_version' => 'dev-main',
|
||||
'version' => 'dev-main',
|
||||
'reference' => '70737383aa72a4fb75363c9d084ec3a7112f8d3b',
|
||||
'reference' => '540212fa49599418676da0d91e03bac2acb6c60a',
|
||||
'type' => 'wordpress-plugin',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
|
|
@ -29,9 +29,9 @@
|
|||
'dev_requirement' => false,
|
||||
),
|
||||
'maxmind-db/reader' => array(
|
||||
'pretty_version' => 'v1.13.1',
|
||||
'version' => '1.13.1.0',
|
||||
'reference' => '2194f58d0f024ce923e685cdf92af3daf9951908',
|
||||
'pretty_version' => 'v1.14.0',
|
||||
'version' => '1.14.0.0',
|
||||
'reference' => 'f3c92f68b3bec42a9aa780368399e03dc6b91e89',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../maxmind-db/reader',
|
||||
'aliases' => array(),
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
'robotstxt/robotstxt-2fa' => array(
|
||||
'pretty_version' => 'dev-main',
|
||||
'version' => 'dev-main',
|
||||
'reference' => '70737383aa72a4fb75363c9d084ec3a7112f8d3b',
|
||||
'reference' => '540212fa49599418676da0d91e03bac2acb6c60a',
|
||||
'type' => 'wordpress-plugin',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
|
|
|
|||
45
vendor/maxmind-db/reader/CHANGELOG.md
vendored
45
vendor/maxmind-db/reader/CHANGELOG.md
vendored
|
|
@ -1,6 +1,51 @@
|
|||
CHANGELOG
|
||||
=========
|
||||
|
||||
1.14.0 (2026-09-10)
|
||||
-------------------
|
||||
|
||||
* Bounded the resources that the pure PHP decoder spends on a single lookup. A
|
||||
crafted database could nest data-section pointers to shared targets so that
|
||||
decoding one record cost exponential time and memory, or point many times at
|
||||
one large value so that the decoder copied far more data than the file holds.
|
||||
The decoder now follows the Reader Resource Limits section of the MaxMind DB
|
||||
specification. Each lookup is limited to 65,536 values, 512 levels of
|
||||
nesting, and 2 MiB of string and bytes payload.
|
||||
* Exceeding a limit throws an `InvalidDatabaseException`.
|
||||
* Opening a database whose metadata exceeds a limit throws the same
|
||||
exception.
|
||||
* A scalar that declares more than 16 bytes, the width of the widest
|
||||
fixed-width type, is rejected as invalid data.
|
||||
* The bundled libmaxminddb used by `--with-maxminddb-bundled` builds of the
|
||||
extension now applies the same decoder limits. The extension throws an
|
||||
`InvalidDatabaseException` when a lookup exceeds them.
|
||||
* The pure PHP reader is about 40% faster on City lookups. It no longer seeks
|
||||
before a read that continues where the last one ended, and it checks read
|
||||
lengths with `strlen()` instead of `ftell()`.
|
||||
* The Windows build configuration now accepts either `libmaxminddb.lib` or
|
||||
`maxminddb.lib` when building the extension. The `lib` prefix was removed
|
||||
in libmaxminddb 1.6.0, but the libmaxminddb that PHP publishes for Windows
|
||||
builds is still 1.5.0, which uses the prefixed name. Pull request by
|
||||
Jean-Baptiste Nahan. GitHub #231.
|
||||
* Replaced `XtOffsetOf()` with `offsetof()`. The `XtOffsetOf()` alias has
|
||||
been removed in PHP 8.6. Pull request by Remi Collet. GitHub #252.
|
||||
* The extension can now be built from a bundled copy of libmaxminddb, on
|
||||
both Unix-like systems and Windows, by passing `--with-maxminddb-bundled`
|
||||
to `configure` (or to `configure.bat` on Windows). This produces an
|
||||
extension that does not depend on a system libmaxminddb, which is a
|
||||
prerequisite for distributing precompiled builds; on Windows it also
|
||||
replaces the 1.5.0 import library that PHP publishes for Windows builds.
|
||||
The default is unchanged: without the flag, the extension links against a
|
||||
system libmaxminddb as before. GitHub #265.
|
||||
* The `conflict` constraint on `ext-maxminddb` in `composer.json` is again
|
||||
updated when a release is cut. The substitution that maintains it stopped
|
||||
matching in April 2024, when the constraint's separator changed from a comma
|
||||
to `||`, so the constraint has read `<1.11.1` through four releases. Users of
|
||||
the C extension should note the effect of reviving it: `ext-maxminddb` is a
|
||||
Composer platform package, so this release conflicts with an older compiled
|
||||
extension and `composer update` will require upgrading the two together.
|
||||
GitHub #266.
|
||||
|
||||
1.13.1 (2025-11-21)
|
||||
-------------------
|
||||
|
||||
|
|
|
|||
39
vendor/maxmind-db/reader/README.md
vendored
39
vendor/maxmind-db/reader/README.md
vendored
|
|
@ -40,7 +40,7 @@ You should now have the file `composer.phar` in your project directory.
|
|||
Run in your project root:
|
||||
|
||||
```
|
||||
php composer.phar require maxmind-db/reader:^1.13.1
|
||||
php composer.phar require maxmind-db/reader:^1.14.0
|
||||
```
|
||||
|
||||
You should now have the files `composer.json` and `composer.lock` as well as
|
||||
|
|
@ -75,7 +75,7 @@ $reader = new Reader('example.mmdb');
|
|||
|
||||
## Installation (RPM)
|
||||
|
||||
RPMs are available in the [official Fedora repository](https://apps.fedoraproject.org/packages/php-maxminddb).
|
||||
RPMs are available in the [official Fedora repository](https://packages.fedoraproject.org/pkgs/php-maxminddb/php-maxminddb/).
|
||||
|
||||
To install on Fedora, run:
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ To install on Fedora, run:
|
|||
dnf install php-maxminddb
|
||||
```
|
||||
|
||||
To install on CentOS or RHEL 7, first [enable the EPEL repository](https://fedoraproject.org/wiki/EPEL)
|
||||
To install on CentOS or RHEL 7, first [enable the EPEL repository](https://docs.fedoraproject.org/en-US/epel/)
|
||||
and then run:
|
||||
|
||||
```bash
|
||||
|
|
@ -139,7 +139,7 @@ for prerequisites including libmaxminddb installation instructions.
|
|||
|
||||
First install [libmaxminddb](https://github.com/maxmind/libmaxminddb) as
|
||||
described in its [README.md
|
||||
file](https://github.com/maxmind/libmaxminddb/blob/main/README.md#installing-from-a-tarball).
|
||||
file](https://github.com/maxmind/libmaxminddb/blob/main/README.md#from-a-named-release-tarball).
|
||||
After successfully installing libmaxmindb, you may install the extension
|
||||
from [PECL](https://pecl.php.net/package/maxminddb):
|
||||
|
||||
|
|
@ -149,18 +149,39 @@ pecl install maxminddb
|
|||
|
||||
### Installing Extension from Source ###
|
||||
|
||||
Alternatively, you may install it from the source. To do so, run the following
|
||||
commands from the top-level directory of this distribution:
|
||||
Alternatively, you may install it from the source. This links against the
|
||||
libmaxminddb installed on your system, so install that first as described
|
||||
above. Run the following commands from the top-level directory of this
|
||||
distribution:
|
||||
|
||||
```
|
||||
cd ext
|
||||
phpize
|
||||
./configure
|
||||
./configure --with-maxminddb
|
||||
make
|
||||
make test
|
||||
sudo make install
|
||||
```
|
||||
|
||||
#### Building without a system libmaxminddb ####
|
||||
|
||||
Passing `--with-maxminddb-bundled` compiles a bundled copy of libmaxminddb
|
||||
into the extension instead, so the result depends on nothing but the C
|
||||
runtime. This is what the precompiled builds use. The bundled sources are a
|
||||
git submodule, so they have to be checked out first:
|
||||
|
||||
```
|
||||
git submodule update --init
|
||||
cd ext
|
||||
phpize
|
||||
./configure --with-maxminddb --with-maxminddb-bundled
|
||||
make
|
||||
make test
|
||||
sudo make install
|
||||
```
|
||||
|
||||
The same flag works on Windows, passed to `configure.bat`.
|
||||
|
||||
You then must load your extension. The recommended method is to add the
|
||||
following to your `php.ini` file:
|
||||
|
||||
|
|
@ -189,7 +210,7 @@ breaking change.
|
|||
Please report all issues with this code using the [GitHub issue tracker](https://github.com/maxmind/MaxMind-DB-Reader-php/issues).
|
||||
|
||||
If you are having an issue with a MaxMind service that is not specific to the
|
||||
client API, please see [our support page](https://www.maxmind.com/en/support).
|
||||
client API, please see [our support page](https://support.maxmind.com/knowledge-base).
|
||||
|
||||
## Requirements ##
|
||||
|
||||
|
|
@ -209,6 +230,6 @@ The MaxMind DB Reader PHP API uses [Semantic Versioning](https://semver.org/).
|
|||
|
||||
## Copyright and License ##
|
||||
|
||||
This software is Copyright (c) 2014-2025 by MaxMind, Inc.
|
||||
This software is Copyright (c) 2014-2026 by MaxMind, Inc.
|
||||
|
||||
This is free software, licensed under the Apache License, Version 2.0.
|
||||
|
|
|
|||
7
vendor/maxmind-db/reader/composer.json
vendored
7
vendor/maxmind-db/reader/composer.json
vendored
|
|
@ -9,7 +9,7 @@
|
|||
{
|
||||
"name": "Gregory J. Oschwald",
|
||||
"email": "goschwald@maxmind.com",
|
||||
"homepage": "https://www.maxmind.com/"
|
||||
"homepage": "https://www.maxmind.com/en/home"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
|
|
@ -22,13 +22,14 @@
|
|||
"maxmind-db/reader-ext": "C extension for significantly faster IP lookups (install via PIE: pie install maxmind-db/reader-ext)"
|
||||
},
|
||||
"conflict": {
|
||||
"ext-maxminddb": "<1.11.1 || >=2.0.0"
|
||||
"ext-maxminddb": "<1.14.0 || >=2.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "3.*",
|
||||
"phpunit/phpunit": ">=8.0.0,<10.0.0",
|
||||
"squizlabs/php_codesniffer": "4.*",
|
||||
"phpstan/phpstan": "*"
|
||||
"phpstan/phpstan": "*",
|
||||
"symfony/polyfill-php80": "^1.33"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
|
|
|||
37
vendor/maxmind-db/reader/ext/bundled-include/maxminddb_config.h
vendored
Normal file
37
vendor/maxmind-db/reader/ext/bundled-include/maxminddb_config.h
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#ifndef MAXMINDDB_CONFIG_H
|
||||
#define MAXMINDDB_CONFIG_H
|
||||
|
||||
/* Supplies the header libmaxminddb's maxminddb.h includes unconditionally and
|
||||
* that libmaxminddb's own build system would generate. We never run that
|
||||
* build.
|
||||
*
|
||||
* This is the canonical account of the arrangement; ext/config.m4 and
|
||||
* ext/config.w32 point here rather than repeating it.
|
||||
*
|
||||
* It is a tracked file rather than something the build systems write at
|
||||
* configure time: generating it meant writing inside the submodule on Windows,
|
||||
* which left it dirty after every build. Nothing includes anything from the
|
||||
* submodule root, so that directory is deliberately off the include path.
|
||||
*
|
||||
* PACKAGE_VERSION lives here rather than on the command line. It has to reach
|
||||
* libmaxminddb's sources, which is what MMDB_lib_version() returns, but our own
|
||||
* ext/maxminddb.c also includes php.h -- and PHP only began stripping PACKAGE_*
|
||||
* from its generated headers in 7.4, so a -D on the global CFLAGS redefines
|
||||
* PHP's macro on 7.2 and 7.3. That is a warning today and a build failure under
|
||||
* --enable-maxminddb-debug, which adds -Werror.
|
||||
*
|
||||
* The #ifndef makes this a no-op wherever PACKAGE_VERSION is already defined:
|
||||
* ext/maxminddb.c includes php.h before maxminddb.h, so it keeps PHP's value
|
||||
* and never sees a redefinition -- harmless, because it reads MMDB_lib_version()
|
||||
* rather than the macro. config.w32 passes its own /D, read out of the
|
||||
* submodule's configure.ac, which likewise wins over this default.
|
||||
*
|
||||
* Keep the version in step with the submodule. test-bundled.yml's "Load the
|
||||
* extension on its own" step compares MMDB_LIB_VERSION against configure.ac on
|
||||
* every build, so a stale value here fails CI rather than shipping.
|
||||
*/
|
||||
#ifndef PACKAGE_VERSION
|
||||
#define PACKAGE_VERSION "1.14.0"
|
||||
#endif
|
||||
|
||||
#endif /* MAXMINDDB_CONFIG_H */
|
||||
133
vendor/maxmind-db/reader/ext/config.m4
vendored
133
vendor/maxmind-db/reader/ext/config.m4
vendored
|
|
@ -2,32 +2,104 @@ PHP_ARG_WITH(maxminddb,
|
|||
[Whether to enable the MaxMind DB Reader extension],
|
||||
[ --with-maxminddb Enable MaxMind DB Reader extension support])
|
||||
|
||||
PHP_ARG_WITH(maxminddb-bundled,
|
||||
[Whether to build the bundled libmaxminddb sources into the extension],
|
||||
[ --with-maxminddb-bundled Build the bundled libmaxminddb sources into the
|
||||
extension instead of linking a system library], no, no)
|
||||
|
||||
PHP_ARG_ENABLE(maxminddb-debug, for MaxMind DB debug support,
|
||||
[ --enable-maxminddb-debug Enable MaxMind DB debug support], no, no)
|
||||
|
||||
dnl --with-maxminddb-bundled on its own is otherwise a silent no-op: the whole
|
||||
dnl block below is skipped, configure exits 0, and make builds nothing.
|
||||
if test "$PHP_MAXMINDDB_BUNDLED" != "no" && test "$PHP_MAXMINDDB" = "no"; then
|
||||
AC_MSG_ERROR([--with-maxminddb-bundled requires --with-maxminddb])
|
||||
fi
|
||||
|
||||
if test $PHP_MAXMINDDB != "no"; then
|
||||
|
||||
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
|
||||
maxminddb_sources="maxminddb.c"
|
||||
|
||||
AC_MSG_CHECKING(for libmaxminddb)
|
||||
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libmaxminddb; then
|
||||
dnl retrieve build options from pkg-config
|
||||
if $PKG_CONFIG libmaxminddb --atleast-version 1.0.0; then
|
||||
LIBMAXMINDDB_INC=`$PKG_CONFIG libmaxminddb --cflags`
|
||||
LIBMAXMINDDB_LIB=`$PKG_CONFIG libmaxminddb --libs`
|
||||
LIBMAXMINDDB_VER=`$PKG_CONFIG libmaxminddb --modversion`
|
||||
AC_MSG_RESULT(found version $LIBMAXMINDDB_VER)
|
||||
else
|
||||
AC_MSG_ERROR(system libmaxminddb must be upgraded to version >= 1.0.0)
|
||||
fi
|
||||
PHP_EVAL_LIBLINE($LIBMAXMINDDB_LIB, MAXMINDDB_SHARED_LIBADD)
|
||||
PHP_EVAL_INCLINE($LIBMAXMINDDB_INC)
|
||||
if test "$PHP_MAXMINDDB_BUNDLED" != "no"; then
|
||||
dnl The arguments are [if-big], [if-little], [if-unknown], [if-universal],
|
||||
dnl and only the first two define the macro, so it is left undefined
|
||||
dnl unless the answer is actually known.
|
||||
dnl
|
||||
dnl Guessing here is not safe. The macro is consumed only by the
|
||||
dnl byte-swaps in get_ieee754_float() and get_ieee754_double(), so a
|
||||
dnl wrong value builds, links and loads perfectly well and then returns
|
||||
dnl garbage for every float and double -- latitude, longitude,
|
||||
dnl accuracyRadius -- while strings and integers stay correct.
|
||||
dnl
|
||||
dnl Under a universal (multi -arch) build no single configure-time value
|
||||
dnl can be right for every slice. In both cases libmaxminddb's own
|
||||
dnl maxminddb.h derives it from __BYTE_ORDER__ behind
|
||||
dnl `#if !defined(MMDB_LITTLE_ENDIAN)`, which is per-architecture correct
|
||||
dnl and is what we want to fall through to.
|
||||
dnl
|
||||
dnl That fall-through relies on __BYTE_ORDER__, which every compiler
|
||||
dnl able to build PHP defines, and maxminddb.h covers Windows
|
||||
dnl separately. Where it is genuinely absent the macro stays undefined,
|
||||
dnl `#if MMDB_LITTLE_ENDIAN` evaluates it as 0, and the build assumes
|
||||
dnl big-endian silently -- correct on a big-endian target and wrong on a
|
||||
dnl little-endian one. Upstream aborts instead, having no universal
|
||||
dnl build to accommodate. Compiling with -Wundef surfaces exactly this
|
||||
dnl case; it is not added here because PHP's own headers do not build
|
||||
dnl warning-free under it, and --enable-maxminddb-debug turns warnings
|
||||
dnl into errors.
|
||||
dnl
|
||||
dnl The third action must be non-empty: autoconf treats an empty
|
||||
dnl argument as absent, and its default for action-if-unknown is to
|
||||
dnl abort rather than fall through. The fourth is passed for symmetry;
|
||||
dnl its default is a harmless AC_DEFINE libmaxminddb never reads.
|
||||
m4_define([_mmdb_endian_unknown],
|
||||
[AC_MSG_NOTICE([endianness undetermined; letting maxminddb.h derive MMDB_LITTLE_ENDIAN from __BYTE_ORDER__])])
|
||||
AC_C_BIGENDIAN([CFLAGS="$CFLAGS -DMMDB_LITTLE_ENDIAN=0"],
|
||||
[CFLAGS="$CFLAGS -DMMDB_LITTLE_ENDIAN=1"],
|
||||
[_mmdb_endian_unknown], [_mmdb_endian_unknown])
|
||||
|
||||
dnl -fvisibility=hidden keeps libmaxminddb's MMDB_* API from becoming
|
||||
dnl part of this object's export table. Vendoring turns those from
|
||||
dnl someone else's exports into ours, and PHP dlopens extensions with
|
||||
dnl RTLD_GLOBAL on common builds, so a process that also loads
|
||||
dnl something linked against a system libmaxminddb could bind across
|
||||
dnl the two. dev-bin/gate-extension.sh asserts the result.
|
||||
dnl
|
||||
dnl -UHAVE_CONFIG_H must precede -DHAVE_CONFIG_H=0: PHP's CPPFLAGS define
|
||||
dnl HAVE_CONFIG_H, and redefining it is a warning that becomes an error
|
||||
dnl under --enable-maxminddb-debug, which adds -Werror.
|
||||
dnl
|
||||
dnl PACKAGE_VERSION is deliberately absent: it is defined in
|
||||
dnl ext/bundled-include/maxminddb_config.h instead, because a -D here
|
||||
dnl also reaches ext/maxminddb.c, which includes php.h -- and PHP only
|
||||
dnl began stripping PACKAGE_* from its generated headers in 7.4, so on
|
||||
dnl 7.2 and 7.3 this redefined PHP's own macro. See that header.
|
||||
CFLAGS="$CFLAGS -fvisibility=hidden -UHAVE_CONFIG_H -DHAVE_CONFIG_H=0 -DMMDB_UINT128_USING_MODE=0 -DMMDB_UINT128_IS_BYTE_ARRAY=1"
|
||||
|
||||
maxminddb_sources="$maxminddb_sources libmaxminddb/src/maxminddb.c libmaxminddb/src/data-pool.c"
|
||||
else
|
||||
AC_MSG_RESULT(pkg-config information missing)
|
||||
AC_MSG_WARN(will use libmaxmxinddb from compiler default path)
|
||||
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
|
||||
|
||||
PHP_CHECK_LIBRARY(maxminddb, MMDB_open)
|
||||
PHP_ADD_LIBRARY(maxminddb, 1, MAXMINDDB_SHARED_LIBADD)
|
||||
AC_MSG_CHECKING(for libmaxminddb)
|
||||
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libmaxminddb; then
|
||||
dnl retrieve build options from pkg-config
|
||||
if $PKG_CONFIG libmaxminddb --atleast-version 1.0.0; then
|
||||
LIBMAXMINDDB_INC=`$PKG_CONFIG libmaxminddb --cflags`
|
||||
LIBMAXMINDDB_LIB=`$PKG_CONFIG libmaxminddb --libs`
|
||||
LIBMAXMINDDB_VER=`$PKG_CONFIG libmaxminddb --modversion`
|
||||
AC_MSG_RESULT(found version $LIBMAXMINDDB_VER)
|
||||
else
|
||||
AC_MSG_ERROR(system libmaxminddb must be upgraded to version >= 1.0.0)
|
||||
fi
|
||||
PHP_EVAL_LIBLINE($LIBMAXMINDDB_LIB, MAXMINDDB_SHARED_LIBADD)
|
||||
PHP_EVAL_INCLINE($LIBMAXMINDDB_INC)
|
||||
else
|
||||
AC_MSG_RESULT(pkg-config information missing)
|
||||
AC_MSG_WARN(will use libmaxmxinddb from compiler default path)
|
||||
|
||||
PHP_CHECK_LIBRARY(maxminddb, MMDB_open)
|
||||
PHP_ADD_LIBRARY(maxminddb, 1, MAXMINDDB_SHARED_LIBADD)
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $PHP_MAXMINDDB_DEBUG != "no"; then
|
||||
|
|
@ -36,5 +108,28 @@ if test $PHP_MAXMINDDB != "no"; then
|
|||
|
||||
PHP_SUBST(MAXMINDDB_SHARED_LIBADD)
|
||||
|
||||
PHP_NEW_EXTENSION(maxminddb, maxminddb.c, $ext_shared)
|
||||
PHP_NEW_EXTENSION(maxminddb, $maxminddb_sources, $ext_shared)
|
||||
|
||||
dnl These have to come after PHP_NEW_EXTENSION, which is what defines
|
||||
dnl $ext_srcdir and $ext_builddir. Without the build directory, the object
|
||||
dnl directory for the bundled sources is never created and they fail to
|
||||
dnl compile.
|
||||
if test "$PHP_MAXMINDDB_BUNDLED" != "no"; then
|
||||
dnl A clone without --recursive otherwise produces a stray "No such
|
||||
dnl file or directory", a *successful* configure -- autoconf-generated
|
||||
dnl configure does not run under set -e -- and then an opaque failure
|
||||
dnl much later at maxminddb.h.
|
||||
if test ! -f "$ext_srcdir/libmaxminddb/src/maxminddb.c"; then
|
||||
AC_MSG_ERROR([--with-maxminddb-bundled needs the bundled libmaxminddb sources; run "git submodule update --init"])
|
||||
fi
|
||||
|
||||
dnl ext/bundled-include supplies maxminddb_config.h, which
|
||||
dnl libmaxminddb's maxminddb.h includes unconditionally and its own
|
||||
dnl build system would generate. Nothing is included from the submodule
|
||||
dnl root, so that directory is deliberately not on the path.
|
||||
PHP_ADD_BUILD_DIR([$ext_builddir/libmaxminddb/src])
|
||||
PHP_ADD_INCLUDE([$ext_srcdir/bundled-include])
|
||||
PHP_ADD_INCLUDE([$ext_srcdir/libmaxminddb/include])
|
||||
PHP_ADD_INCLUDE([$ext_srcdir/libmaxminddb/src])
|
||||
fi
|
||||
fi
|
||||
|
|
|
|||
113
vendor/maxmind-db/reader/ext/config.w32
vendored
113
vendor/maxmind-db/reader/ext/config.w32
vendored
|
|
@ -1,10 +1,117 @@
|
|||
ARG_WITH("maxminddb", "Enable MaxMind DB Reader extension support", "no");
|
||||
ARG_WITH("maxminddb-bundled", "Build the bundled libmaxminddb sources into the extension instead of linking a system library", "no");
|
||||
|
||||
if (PHP_MAXMINDDB == "yes") {
|
||||
if (CHECK_HEADER_ADD_INCLUDE("maxminddb.h", "CFLAGS_MAXMINDDB", PHP_MAXMINDDB + ";" + PHP_PHP_BUILD + "\\include\\maxminddb") &&
|
||||
CHECK_LIB("libmaxminddb.lib", "maxminddb", PHP_MAXMINDDB)) {
|
||||
if (PHP_MAXMINDDB_BUNDLED != "no") {
|
||||
var maxminddb_bundled = configure_module_dirname + "\\libmaxminddb";
|
||||
|
||||
/* The file, not just the directory: an empty or half-populated leftover
|
||||
* src\\ passes a folder check and then fails opaquely at compile time,
|
||||
* which is what the matching check in config.m4 was added to avoid. */
|
||||
if (!FSO.FileExists(maxminddb_bundled + "\\src\\maxminddb.c")) {
|
||||
ERROR("--with-maxminddb-bundled needs the bundled libmaxminddb sources; run \"git submodule update --init\"");
|
||||
}
|
||||
|
||||
/* Read the version out of the submodule rather than repeating it here.
|
||||
* Nothing else checks this file -- there is no Windows workflow in this
|
||||
* repository -- so a bump that updated config.m4 and forgot this line
|
||||
* would ship a PACKAGE_VERSION that lies, with nothing to notice it.
|
||||
* config.m4 keeps a literal because test-bundled.yml compares
|
||||
* MMDB_LIB_VERSION against configure.ac on every build. */
|
||||
var maxminddb_ac = file_get_contents(maxminddb_bundled + "\\configure.ac");
|
||||
/* The match is captured rather than read back out of RegExp.$1, which is
|
||||
* engine-global state shared with every other config.w32 evaluated in
|
||||
* the same scope. */
|
||||
var maxminddb_match = maxminddb_ac
|
||||
? maxminddb_ac.match(/AC_INIT\(\[libmaxminddb\], \[([^\]]+)\]/)
|
||||
: null;
|
||||
if (!maxminddb_match) {
|
||||
ERROR("could not read the libmaxminddb version from ext/libmaxminddb/configure.ac");
|
||||
}
|
||||
var maxminddb_version = maxminddb_match[1];
|
||||
|
||||
/* ext/bundled-include supplies maxminddb_config.h, which
|
||||
* libmaxminddb's maxminddb.h includes unconditionally and its own build
|
||||
* system would generate. It is a tracked file: writing it at configure
|
||||
* time meant writing into the submodule, which left it dirty after
|
||||
* every build. Nothing is included from the submodule root, so that
|
||||
* directory is deliberately not on the path. */
|
||||
ADD_FLAG("CFLAGS_MAXMINDDB", '/I "' + configure_module_dirname + '\\bundled-include" ' +
|
||||
'/I "' + maxminddb_bundled + '\\include" ' +
|
||||
'/I "' + maxminddb_bundled + '\\src"');
|
||||
|
||||
/* The uint128 defines match ext/config.m4. Three things deliberately do
|
||||
* not: HAVE_CONFIG_H is left alone here (below); MMDB_LITTLE_ENDIAN is
|
||||
* hardcoded because every Windows target is little-endian, where
|
||||
* config.m4 derives it and may leave it undefined; and there is no
|
||||
* -fvisibility=hidden counterpart, because MSVC exports nothing that is
|
||||
* not marked __declspec(dllexport).
|
||||
* config.m4 has to define it as 0 because PHP's Unix CPPFLAGS already
|
||||
* define it, and libmaxminddb's maxminddb.c tests the *value* with
|
||||
* `#if HAVE_CONFIG_H`, so it would otherwise include the config.h it
|
||||
* finds on the include path -- PHP's. Our own maxminddb.c tests
|
||||
* *definedness* with `#ifdef`, which is why =0 suppresses libmaxminddb's
|
||||
* include without suppressing ours. That asymmetry is the hinge of this
|
||||
* design and would break if upstream ever switched to `#ifdef`.
|
||||
*
|
||||
* The Windows build never defines HAVE_CONFIG_H, so libmaxminddb
|
||||
* already does the right thing, and defining it here would instead
|
||||
* make our own maxminddb.c include a config.h that does not exist.
|
||||
*
|
||||
* MSVC has no unsigned __int128, so the byte array is the only option
|
||||
* for uint128 values. Both this file and config.m4 have to define
|
||||
* MMDB_UINT128_IS_BYTE_ARRAY the same way, because it decides the
|
||||
* layout of the MMDB_entry_data_s union that maxminddb.c and the
|
||||
* bundled sources pass between each other.
|
||||
*
|
||||
* MMDB_lib_version() returns PACKAGE_VERSION, and the extension exposes
|
||||
* that as MMDB_LIB_VERSION and through phpinfo(). The inner quotes are
|
||||
* escaped so that they survive the compiler's own command line parsing
|
||||
* and PACKAGE_VERSION ends up a string literal. */
|
||||
ADD_FLAG("CFLAGS_MAXMINDDB", '/D MMDB_LITTLE_ENDIAN=1 /D MMDB_UINT128_USING_MODE=0 ' +
|
||||
'/D MMDB_UINT128_IS_BYTE_ARRAY=1 /D PACKAGE_VERSION=\\"' + maxminddb_version + '\\"');
|
||||
|
||||
/* MaxMind's Python reader passes -wd4068 for these same sources.
|
||||
* libmaxminddb guards its #pragma clang lines with __clang__, so cl
|
||||
* should not warn about them, but keeping the suppression costs nothing
|
||||
* and survives a bump that drops a guard. */
|
||||
ADD_FLAG("CFLAGS_MAXMINDDB", "/wd4068");
|
||||
|
||||
/* MMDB_open() calls WSAStartup() and maxminddb.h pulls in winsock2.h.
|
||||
* php-src already has ws2_32.lib in $(LIBS), but sapi/cli and sapi/cgi
|
||||
* ask for it explicitly too, and the dependency is ours now. */
|
||||
ADD_FLAG("LIBS_MAXMINDDB", "ws2_32.lib");
|
||||
|
||||
EXTENSION("maxminddb", "maxminddb.c");
|
||||
|
||||
/* This has to come after EXTENSION, which is what makes CFLAGS_MAXMINDDB
|
||||
* reach the compiler calls that ADD_SOURCES writes.
|
||||
*
|
||||
* The fourth argument is the object directory, and it is not optional
|
||||
* here: libmaxminddb/src/maxminddb.c and our own maxminddb.c share a
|
||||
* basename. In a php-src tree ADD_SOURCES derives the object directory
|
||||
* from its first argument, so the two would land in separate
|
||||
* directories and nothing would collide -- that is how ext/gd gets away
|
||||
* with libgd/gd.c next to gd.c. Under phpize, which is how this
|
||||
* extension is built for Windows, confutils.js takes a different branch
|
||||
* in ADD_SOURCES that derives the build directory from the dirname of
|
||||
* each file_list entry and ignores the fourth argument. Our entries are
|
||||
* bare filenames, so both sources resolve to
|
||||
* $(BUILD_DIR)\maxminddb.obj, the makefile gets two rules for one
|
||||
* target, and whichever compiles last wins. When libmaxminddb's won,
|
||||
* the DLL linked without our get_module() and PHP rejected it with
|
||||
* "Invalid library (maybe not a PHP library)" -- a build that succeeds
|
||||
* and produces an extension that cannot load.
|
||||
*
|
||||
* Passing the object directory explicitly takes the branch that honours
|
||||
* it, so these objects land in $(BUILD_DIR)\libmaxminddb. ADD_SOURCES
|
||||
* registers that in build_dirs and configure creates it. */
|
||||
ADD_SOURCES(maxminddb_bundled + "\\src", "maxminddb.c data-pool.c",
|
||||
"maxminddb", "libmaxminddb");
|
||||
} else if (CHECK_HEADER_ADD_INCLUDE("maxminddb.h", "CFLAGS_MAXMINDDB", PHP_MAXMINDDB + ";" + PHP_PHP_BUILD + "\\include\\maxminddb") &&
|
||||
CHECK_LIB("libmaxminddb.lib;maxminddb.lib", "maxminddb", PHP_MAXMINDDB)) {
|
||||
EXTENSION("maxminddb", "maxminddb.c");
|
||||
} else {
|
||||
WARNING('Could not find maxminddb.h or libmaxminddb.lib; skipping');
|
||||
WARNING('Could not find maxminddb.h, libmaxminddb.lib, or maxminddb.lib; skipping');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
4
vendor/maxmind-db/reader/ext/maxminddb.c
vendored
4
vendor/maxmind-db/reader/ext/maxminddb.c
vendored
|
|
@ -110,7 +110,7 @@ static zend_class_entry *maxminddb_ce, *maxminddb_exception_ce, *metadata_ce;
|
|||
|
||||
static inline maxminddb_obj *
|
||||
php_maxminddb_fetch_object(zend_object *obj TSRMLS_DC) {
|
||||
return (maxminddb_obj *)((char *)(obj)-XtOffsetOf(maxminddb_obj, std));
|
||||
return (maxminddb_obj *)((char *)(obj)-offsetof(maxminddb_obj, std));
|
||||
}
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_maxminddbreader_construct, 0, 0, 1)
|
||||
|
|
@ -781,7 +781,7 @@ PHP_MINIT_FUNCTION(maxminddb) {
|
|||
zend_get_std_object_handlers(),
|
||||
sizeof(zend_object_handlers));
|
||||
maxminddb_obj_handlers.clone_obj = NULL;
|
||||
maxminddb_obj_handlers.offset = XtOffsetOf(maxminddb_obj, std);
|
||||
maxminddb_obj_handlers.offset = offsetof(maxminddb_obj, std);
|
||||
maxminddb_obj_handlers.free_obj = maxminddb_free_storage;
|
||||
zend_declare_class_constant_string(maxminddb_ce,
|
||||
"MMDB_LIB_VERSION",
|
||||
|
|
|
|||
2
vendor/maxmind-db/reader/ext/php_maxminddb.h
vendored
2
vendor/maxmind-db/reader/ext/php_maxminddb.h
vendored
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#ifndef PHP_MAXMINDDB_H
|
||||
#define PHP_MAXMINDDB_H 1
|
||||
#define PHP_MAXMINDDB_VERSION "1.13.1"
|
||||
#define PHP_MAXMINDDB_VERSION "1.14.0"
|
||||
#define PHP_MAXMINDDB_EXTNAME "maxminddb"
|
||||
|
||||
extern zend_module_entry maxminddb_module_entry;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,16 @@
|
|||
--TEST--
|
||||
openbase_dir is followed
|
||||
--SKIPIF--
|
||||
<?php
|
||||
// Deliberately not skipped when the extension is missing: 001 and 002 both do
|
||||
// that, so on Unix this is the only test that fails rather than skips when a
|
||||
// build produces an extension that cannot load. The Windows skip below gives
|
||||
// that property up on Windows, which is why test-bundled.yml's Windows job
|
||||
// gates the DLL explicitly rather than relying on the phpt run.
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
echo 'skip both paths below are POSIX-specific';
|
||||
}
|
||||
?>
|
||||
--INI--
|
||||
open_basedir=/--dne--
|
||||
--FILE--
|
||||
|
|
|
|||
54
vendor/maxmind-db/reader/lychee.toml
vendored
Normal file
54
vendor/maxmind-db/reader/lychee.toml
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
# Lychee link checker configuration
|
||||
# https://lychee.cli.rs/#/usage/config
|
||||
#
|
||||
# Run locally with:
|
||||
# lychee './**/*.md' './src/**/*.php' './composer.json'
|
||||
|
||||
# Include URL fragments in checks
|
||||
include_fragments = true
|
||||
|
||||
# Don't allow any redirects, so links that have moved are surfaced and updated
|
||||
# to their canonical destination.
|
||||
max_redirects = 0
|
||||
|
||||
# Accept these HTTP status codes
|
||||
# 100-103: Informational responses
|
||||
# 200-299: Success responses
|
||||
# 403: Forbidden (some sites use this for rate limiting)
|
||||
# 429: Too Many Requests
|
||||
# 500-599: Server errors (temporary issues shouldn't fail CI)
|
||||
# 999: LinkedIn's custom status code
|
||||
accept = ["100..=103", "200..=299", "403", "429", "500..=599", "999"]
|
||||
|
||||
# Exclude URL patterns from checking (treated as regular expressions)
|
||||
exclude = [
|
||||
'^file://',
|
||||
# Live / auth-gated endpoints that appear as string literals or require login
|
||||
'^https://geoip\.maxmind\.com',
|
||||
'^https://geolite\.info',
|
||||
'^https://minfraud\.maxmind\.com',
|
||||
'^https://sandbox\.maxmind\.com',
|
||||
'^https://updates\.maxmind\.com',
|
||||
'^https://www\.maxmind\.com/en/accounts/',
|
||||
'^https://www\.maxmind\.com/en/account/login',
|
||||
# Placeholders / local
|
||||
'^https?://example\.(com|org|net)',
|
||||
'^http://localhost',
|
||||
'127\.0\.0\.1',
|
||||
]
|
||||
|
||||
# Exclude file paths from getting checked (treated as regular expressions)
|
||||
exclude_path = [
|
||||
'(^|/)node_modules/',
|
||||
'(^|/)vendor/',
|
||||
'(^|/)\.git/',
|
||||
# Changelog: historical entries are preserved as-is, not rewritten
|
||||
'(^|/)CHANGELOG\.md$',
|
||||
]
|
||||
|
||||
# Cache results for 1 day to speed up repeated checks
|
||||
cache = true
|
||||
max_cache_age = "1d"
|
||||
|
||||
# Skip missing input files instead of erroring
|
||||
skip_missing = true
|
||||
69
vendor/maxmind-db/reader/mise.lock
vendored
Normal file
69
vendor/maxmind-db/reader/mise.lock
vendored
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
# @generated - this file is auto-generated by `mise lock` https://mise.jdx.dev/dev-tools/mise-lock.html
|
||||
|
||||
[[tools."github:composer/composer"]]
|
||||
version = "2.10.2"
|
||||
backend = "github:composer/composer"
|
||||
|
||||
[tools."github:composer/composer"."platforms.linux-arm64"]
|
||||
checksum = "sha256:5ee7125f8a30a34d246cefdc0bc85b8a783b28f2aec968994118512350d28027"
|
||||
url = "https://github.com/composer/composer/releases/download/2.10.2/composer.phar"
|
||||
url_api = "https://api.github.com/repos/composer/composer/releases/assets/463051343"
|
||||
provenance = "github-attestations"
|
||||
|
||||
[tools."github:composer/composer"."platforms.linux-arm64-musl"]
|
||||
checksum = "sha256:5ee7125f8a30a34d246cefdc0bc85b8a783b28f2aec968994118512350d28027"
|
||||
url = "https://github.com/composer/composer/releases/download/2.10.2/composer.phar"
|
||||
url_api = "https://api.github.com/repos/composer/composer/releases/assets/463051343"
|
||||
provenance = "github-attestations"
|
||||
|
||||
[tools."github:composer/composer"."platforms.linux-x64"]
|
||||
checksum = "sha256:5ee7125f8a30a34d246cefdc0bc85b8a783b28f2aec968994118512350d28027"
|
||||
url = "https://github.com/composer/composer/releases/download/2.10.2/composer.phar"
|
||||
url_api = "https://api.github.com/repos/composer/composer/releases/assets/463051343"
|
||||
provenance = "github-attestations"
|
||||
|
||||
[tools."github:composer/composer"."platforms.linux-x64-musl"]
|
||||
checksum = "sha256:5ee7125f8a30a34d246cefdc0bc85b8a783b28f2aec968994118512350d28027"
|
||||
url = "https://github.com/composer/composer/releases/download/2.10.2/composer.phar"
|
||||
url_api = "https://api.github.com/repos/composer/composer/releases/assets/463051343"
|
||||
provenance = "github-attestations"
|
||||
|
||||
[tools."github:composer/composer"."platforms.macos-arm64"]
|
||||
checksum = "sha256:5ee7125f8a30a34d246cefdc0bc85b8a783b28f2aec968994118512350d28027"
|
||||
url = "https://github.com/composer/composer/releases/download/2.10.2/composer.phar"
|
||||
url_api = "https://api.github.com/repos/composer/composer/releases/assets/463051343"
|
||||
provenance = "github-attestations"
|
||||
|
||||
[tools."github:composer/composer"."platforms.windows-x64"]
|
||||
checksum = "sha256:5ee7125f8a30a34d246cefdc0bc85b8a783b28f2aec968994118512350d28027"
|
||||
url = "https://github.com/composer/composer/releases/download/2.10.2/composer.phar"
|
||||
url_api = "https://api.github.com/repos/composer/composer/releases/assets/463051343"
|
||||
provenance = "github-attestations"
|
||||
|
||||
[[tools.lychee]]
|
||||
version = "0.23.0"
|
||||
backend = "aqua:lycheeverse/lychee"
|
||||
|
||||
[tools.lychee."platforms.linux-arm64"]
|
||||
checksum = "sha256:97eb93b02a7d78a752fc33e5b0983439ccaadbf3db952b68a0a4401acd92e6e0"
|
||||
url = "https://github.com/lycheeverse/lychee/releases/download/lychee-v0.23.0/lychee-aarch64-unknown-linux-gnu.tar.gz"
|
||||
|
||||
[tools.lychee."platforms.linux-arm64-musl"]
|
||||
checksum = "sha256:97eb93b02a7d78a752fc33e5b0983439ccaadbf3db952b68a0a4401acd92e6e0"
|
||||
url = "https://github.com/lycheeverse/lychee/releases/download/lychee-v0.23.0/lychee-aarch64-unknown-linux-gnu.tar.gz"
|
||||
|
||||
[tools.lychee."platforms.linux-x64"]
|
||||
checksum = "sha256:5538440d2c69a45a0a09983271e5dee0c2fe7137d8035d25b2632e10a66a090a"
|
||||
url = "https://github.com/lycheeverse/lychee/releases/download/lychee-v0.23.0/lychee-x86_64-unknown-linux-musl.tar.gz"
|
||||
|
||||
[tools.lychee."platforms.linux-x64-musl"]
|
||||
checksum = "sha256:5538440d2c69a45a0a09983271e5dee0c2fe7137d8035d25b2632e10a66a090a"
|
||||
url = "https://github.com/lycheeverse/lychee/releases/download/lychee-v0.23.0/lychee-x86_64-unknown-linux-musl.tar.gz"
|
||||
|
||||
[tools.lychee."platforms.macos-arm64"]
|
||||
checksum = "sha256:4c8034900e11083b68ac6f6582c377ff1f704e268991999e09d717973e493e7f"
|
||||
url = "https://github.com/lycheeverse/lychee/releases/download/lychee-v0.23.0/lychee-arm64-macos.dmg"
|
||||
|
||||
[tools.lychee."platforms.windows-x64"]
|
||||
checksum = "sha256:0fda7ff0a60c0250939fc25361c2d4e6e7853c31c996733fdd5a1dd760bcb824"
|
||||
url = "https://github.com/lycheeverse/lychee/releases/download/lychee-v0.23.0/lychee-x86_64-windows.exe"
|
||||
10
vendor/maxmind-db/reader/mise.toml
vendored
Normal file
10
vendor/maxmind-db/reader/mise.toml
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
[settings]
|
||||
lockfile = true
|
||||
|
||||
[tools]
|
||||
"github:composer/composer" = "latest"
|
||||
lychee = "latest"
|
||||
|
||||
[tasks.check-links]
|
||||
description = "Check links with lychee"
|
||||
run = "lychee --no-progress './**/*.md' './src/**/*.php' './composer.json'"
|
||||
48
vendor/maxmind-db/reader/package.xml
vendored
48
vendor/maxmind-db/reader/package.xml
vendored
|
|
@ -14,17 +14,57 @@
|
|||
<email>goschwald@maxmind.com</email>
|
||||
<active>yes</active>
|
||||
</lead>
|
||||
<date>2025-11-21</date>
|
||||
<date>2026-09-10</date>
|
||||
<version>
|
||||
<release>1.13.1</release>
|
||||
<api>1.13.1</api>
|
||||
<release>1.14.0</release>
|
||||
<api>1.14.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="https://github.com/maxmind/MaxMind-DB-Reader-php/blob/main/LICENSE">Apache License 2.0</license>
|
||||
<notes>* First PIE release. No other changes.</notes>
|
||||
<notes>* Bounded the resources that the pure PHP decoder spends on a single lookup. A
|
||||
crafted database could nest data-section pointers to shared targets so that
|
||||
decoding one record cost exponential time and memory, or point many times at
|
||||
one large value so that the decoder copied far more data than the file holds.
|
||||
The decoder now follows the Reader Resource Limits section of the MaxMind DB
|
||||
specification. Each lookup is limited to 65,536 values, 512 levels of
|
||||
nesting, and 2 MiB of string and bytes payload.
|
||||
* Exceeding a limit throws an `InvalidDatabaseException`.
|
||||
* Opening a database whose metadata exceeds a limit throws the same
|
||||
exception.
|
||||
* A scalar that declares more than 16 bytes, the width of the widest
|
||||
fixed-width type, is rejected as invalid data.
|
||||
* The bundled libmaxminddb used by `--with-maxminddb-bundled` builds of the
|
||||
extension now applies the same decoder limits. The extension throws an
|
||||
`InvalidDatabaseException` when a lookup exceeds them.
|
||||
* The pure PHP reader is about 40% faster on City lookups. It no longer seeks
|
||||
before a read that continues where the last one ended, and it checks read
|
||||
lengths with `strlen()` instead of `ftell()`.
|
||||
* The Windows build configuration now accepts either `libmaxminddb.lib` or
|
||||
`maxminddb.lib` when building the extension. The `lib` prefix was removed
|
||||
in libmaxminddb 1.6.0, but the libmaxminddb that PHP publishes for Windows
|
||||
builds is still 1.5.0, which uses the prefixed name. Pull request by
|
||||
Jean-Baptiste Nahan. GitHub #231.
|
||||
* Replaced `XtOffsetOf()` with `offsetof()`. The `XtOffsetOf()` alias has
|
||||
been removed in PHP 8.6. Pull request by Remi Collet. GitHub #252.
|
||||
* The extension can now be built from a bundled copy of libmaxminddb, on
|
||||
both Unix-like systems and Windows, by passing `--with-maxminddb-bundled`
|
||||
to `configure` (or to `configure.bat` on Windows). This produces an
|
||||
extension that does not depend on a system libmaxminddb, which is a
|
||||
prerequisite for distributing precompiled builds; on Windows it also
|
||||
replaces the 1.5.0 import library that PHP publishes for Windows builds.
|
||||
The default is unchanged: without the flag, the extension links against a
|
||||
system libmaxminddb as before. GitHub #265.
|
||||
* The `conflict` constraint on `ext-maxminddb` in `composer.json` is again
|
||||
updated when a release is cut. The substitution that maintains it stopped
|
||||
matching in April 2024, when the constraint's separator changed from a comma
|
||||
to `||`, so the constraint has read `<1.11.1` through four releases. Users of
|
||||
the C extension should note the effect of reviving it: `ext-maxminddb` is a
|
||||
Composer platform package, so this release conflicts with an older compiled
|
||||
extension and `composer update` will require upgrading the two together.
|
||||
GitHub #266.</notes>
|
||||
<contents>
|
||||
<dir name="/">
|
||||
<file role="doc" name="LICENSE"/>
|
||||
|
|
|
|||
|
|
@ -45,6 +45,11 @@ class Reader
|
|||
*/
|
||||
private $fileHandle;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $lookupInProgress = false;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
@ -62,7 +67,7 @@ class Reader
|
|||
|
||||
/**
|
||||
* Constructs a Reader for the MaxMind DB format. The file passed to it must
|
||||
* be a valid MaxMind DB file such as a GeoIp2 database file.
|
||||
* be a valid MaxMind DB file such as a GeoIP database file.
|
||||
*
|
||||
* @param string $database the MaxMind DB file to use
|
||||
*
|
||||
|
|
@ -118,7 +123,7 @@ class Reader
|
|||
*
|
||||
* @param string $ipAddress the IP address to look up
|
||||
*
|
||||
* @throws \BadMethodCallException if this method is called on a closed database
|
||||
* @throws \BadMethodCallException if the database is closed or another lookup is in progress
|
||||
* @throws \InvalidArgumentException if something other than a single IP address is passed to the method
|
||||
* @throws InvalidDatabaseException
|
||||
* if the database is invalid or there is an error reading
|
||||
|
|
@ -143,7 +148,7 @@ class Reader
|
|||
*
|
||||
* @param string $ipAddress the IP address to look up
|
||||
*
|
||||
* @throws \BadMethodCallException if this method is called on a closed database
|
||||
* @throws \BadMethodCallException if the database is closed or another lookup is in progress
|
||||
* @throws \InvalidArgumentException if something other than a single IP address is passed to the method
|
||||
* @throws InvalidDatabaseException
|
||||
* if the database is invalid or there is an error reading
|
||||
|
|
@ -166,12 +171,25 @@ class Reader
|
|||
);
|
||||
}
|
||||
|
||||
[$pointer, $prefixLen] = $this->findAddressInTree($ipAddress);
|
||||
if ($pointer === 0) {
|
||||
return [null, $prefixLen];
|
||||
if ($this->lookupInProgress) {
|
||||
throw new \BadMethodCallException(
|
||||
'A lookup is already in progress on this reader. Use a separate reader for nested lookups.'
|
||||
);
|
||||
}
|
||||
// A stream wrapper can call back into this reader during a read.
|
||||
// Reject nested lookups before they can move the shared stream.
|
||||
$this->lookupInProgress = true;
|
||||
|
||||
return [$this->resolveDataPointer($pointer), $prefixLen];
|
||||
try {
|
||||
[$pointer, $prefixLen] = $this->findAddressInTree($ipAddress);
|
||||
if ($pointer === 0) {
|
||||
return [null, $prefixLen];
|
||||
}
|
||||
|
||||
return [$this->resolveDataPointer($pointer), $prefixLen];
|
||||
} finally {
|
||||
$this->lookupInProgress = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -30,6 +30,29 @@ class Decoder
|
|||
*/
|
||||
private $switchByteOrder;
|
||||
|
||||
/**
|
||||
* Remaining decoded-value allowance for the current decode() call.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $budget = 0;
|
||||
|
||||
/**
|
||||
* Remaining string and bytes payload allowance for the current decode()
|
||||
* call.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $byteBudget = 0;
|
||||
|
||||
/**
|
||||
* Stream position after the last read of the current decode() call, or -1
|
||||
* when unknown.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $position = -1;
|
||||
|
||||
private const _EXTENDED = 0;
|
||||
private const _POINTER = 1;
|
||||
private const _UTF8_STRING = 2;
|
||||
|
|
@ -47,6 +70,30 @@ class Decoder
|
|||
private const _BOOLEAN = 14;
|
||||
private const _FLOAT = 15;
|
||||
|
||||
// Per-lookup decode limits recommended by the MaxMind DB specification. The
|
||||
// depth limit stops pointer cycles and over-deep data. The value limit
|
||||
// stops a pointer fan-out, where nested pointers to shared targets would
|
||||
// otherwise cost 2**depth decode operations. The count follows the
|
||||
// specification's flat rule: the root is one value, each array and map
|
||||
// charges its declared children (a map entry costs two, key and value),
|
||||
// and a pointer costs nothing beyond the value it resolves to, which its
|
||||
// container already charged.
|
||||
private const MAX_DEPTH = 512;
|
||||
private const MAX_VALUES = 1 << 16;
|
||||
|
||||
// The value limit alone does not stop payload amplification: an array of
|
||||
// pointers to one large string or bytes value keeps the value count low
|
||||
// while forcing the reader to copy the target once per pointer. This
|
||||
// second limit bounds the total string and bytes payload copied for one
|
||||
// lookup to 2 MiB. Re-decoding a shared target charges its payload again.
|
||||
private const MAX_PAYLOAD_BYTES = 1 << 21;
|
||||
|
||||
// A fixed-width scalar (a float, double, or integer) never needs more than
|
||||
// 16 bytes (the width of a uint128). A larger declared size is either
|
||||
// corrupt or an attempt to amplify the read of an oversized variable-length
|
||||
// integer, so it is rejected before the bytes are materialized.
|
||||
private const MAX_SCALAR_BYTES = 16;
|
||||
|
||||
/**
|
||||
* @param resource $fileStream
|
||||
*/
|
||||
|
|
@ -68,7 +115,25 @@ class Decoder
|
|||
*/
|
||||
public function decode(int $offset): array
|
||||
{
|
||||
$ctrlByte = \ord(Util::read($this->fileStream, $offset, 1));
|
||||
// Reset both budgets for each lookup. Charge the root value here and
|
||||
// container children when entering each container. Reader prevents
|
||||
// nested lookups from moving its stream during a decode.
|
||||
$this->budget = self::MAX_VALUES - 1;
|
||||
$this->byteBudget = self::MAX_PAYLOAD_BYTES;
|
||||
|
||||
// Other readers of the stream, such as the search tree walk, may have
|
||||
// moved it since the last call.
|
||||
$this->position = -1;
|
||||
|
||||
return $this->decodeWithBudget($offset, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<mixed>
|
||||
*/
|
||||
private function decodeWithBudget(int $offset, int $depth, bool $allowPointer = true): array
|
||||
{
|
||||
$ctrlByte = \ord($this->read($offset, 1));
|
||||
++$offset;
|
||||
|
||||
$type = $ctrlByte >> 5;
|
||||
|
|
@ -77,6 +142,12 @@ class Decoder
|
|||
// use the size to determine the length of the pointer and then follow
|
||||
// it.
|
||||
if ($type === self::_POINTER) {
|
||||
if (!$allowPointer) {
|
||||
throw new InvalidDatabaseException(
|
||||
'The MaxMind DB file contains a pointer to another pointer'
|
||||
);
|
||||
}
|
||||
|
||||
[$pointer, $offset] = $this->decodePointer($ctrlByte, $offset);
|
||||
|
||||
// for unit testing
|
||||
|
|
@ -84,13 +155,22 @@ class Decoder
|
|||
return [$pointer];
|
||||
}
|
||||
|
||||
[$result] = $this->decode($pointer);
|
||||
if ($depth >= self::MAX_DEPTH) {
|
||||
throw new InvalidDatabaseException(
|
||||
'The MaxMind DB file exceeds the maximum depth'
|
||||
);
|
||||
}
|
||||
|
||||
// The value at the pointer's position was charged by its containing
|
||||
// array or map, so the target costs nothing more. Only the depth
|
||||
// grows.
|
||||
[$result] = $this->decodeWithBudget($pointer, $depth + 1, false);
|
||||
|
||||
return [$result, $offset];
|
||||
}
|
||||
|
||||
if ($type === self::_EXTENDED) {
|
||||
$nextByte = \ord(Util::read($this->fileStream, $offset, 1));
|
||||
$nextByte = \ord($this->read($offset, 1));
|
||||
|
||||
$type = $nextByte + 7;
|
||||
|
||||
|
|
@ -108,7 +188,7 @@ class Decoder
|
|||
|
||||
[$size, $offset] = $this->sizeFromCtrlByte($ctrlByte, $offset);
|
||||
|
||||
return $this->decodeByType($type, $offset, $size);
|
||||
return $this->decodeByType($type, $offset, $size, $depth);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -116,27 +196,54 @@ class Decoder
|
|||
*
|
||||
* @return array{0:mixed, 1:int}
|
||||
*/
|
||||
private function decodeByType(int $type, int $offset, int $size): array
|
||||
private function decodeByType(int $type, int $offset, int $size, int $depth): array
|
||||
{
|
||||
switch ($type) {
|
||||
case self::_MAP:
|
||||
return $this->decodeMap($size, $offset);
|
||||
return $this->decodeMap($size, $offset, $depth);
|
||||
|
||||
case self::_ARRAY:
|
||||
return $this->decodeArray($size, $offset);
|
||||
return $this->decodeArray($size, $offset, $depth);
|
||||
|
||||
case self::_BOOLEAN:
|
||||
return [$this->decodeBoolean($size), $offset];
|
||||
|
||||
case self::_BYTES:
|
||||
case self::_UTF8_STRING:
|
||||
// A string or bytes value is copied into a native string, so N
|
||||
// pointers to one large value copy N times its length. Charge
|
||||
// the payload against the byte budget wherever it is decoded,
|
||||
// including inline inside a pointed-to container, so a shared
|
||||
// target recharges each time it is followed. Compare before
|
||||
// subtracting so an oversized declared size cannot drive the
|
||||
// budget negative. A total exactly at the limit is allowed.
|
||||
if ($size > $this->byteBudget) {
|
||||
throw new InvalidDatabaseException(
|
||||
'The MaxMind DB file exceeds the maximum payload size'
|
||||
);
|
||||
}
|
||||
$this->byteBudget -= $size;
|
||||
|
||||
return [$this->read($offset, $size), $offset + $size];
|
||||
}
|
||||
|
||||
// The remaining valid types are fixed-width scalars, none wider than a
|
||||
// uint128. A few other control bytes also reach here: the container
|
||||
// (12) and end-marker (13) types, and any unknown extended type. The
|
||||
// size guard below rejects one that declares an oversized size, and the
|
||||
// default case at the end of the switch rejects the rest. Reject an
|
||||
// oversized declared size before materializing the bytes, so an
|
||||
// oversized variable-length integer cannot amplify the read.
|
||||
if ($size > self::MAX_SCALAR_BYTES) {
|
||||
throw new InvalidDatabaseException(
|
||||
"The MaxMind DB file's data section contains bad data (unknown data type or corrupt data)"
|
||||
);
|
||||
}
|
||||
|
||||
$newOffset = $offset + $size;
|
||||
$bytes = Util::read($this->fileStream, $offset, $size);
|
||||
$bytes = $this->read($offset, $size);
|
||||
|
||||
switch ($type) {
|
||||
case self::_BYTES:
|
||||
case self::_UTF8_STRING:
|
||||
return [$bytes, $newOffset];
|
||||
|
||||
case self::_DOUBLE:
|
||||
$this->verifySize(8, $size);
|
||||
|
||||
|
|
@ -163,6 +270,36 @@ class Decoder
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads from the stream, seeking only when the read does not continue where
|
||||
* the previous one ended.
|
||||
*
|
||||
* @param int<0, max> $numberOfBytes
|
||||
*/
|
||||
private function read(int $offset, int $numberOfBytes): string
|
||||
{
|
||||
if ($numberOfBytes === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$stream = $this->fileStream;
|
||||
if ($offset !== $this->position && fseek($stream, $offset) !== 0) {
|
||||
$this->position = -1;
|
||||
|
||||
throw new InvalidDatabaseException('The MaxMind DB file contains bad data');
|
||||
}
|
||||
|
||||
$value = fread($stream, $numberOfBytes);
|
||||
if ($value === false || \strlen($value) !== $numberOfBytes) {
|
||||
$this->position = -1;
|
||||
|
||||
throw new InvalidDatabaseException('The MaxMind DB file contains bad data');
|
||||
}
|
||||
$this->position = $offset + $numberOfBytes;
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
private function verifySize(int $expected, int $actual): void
|
||||
{
|
||||
if ($expected !== $actual) {
|
||||
|
|
@ -172,15 +309,40 @@ class Decoder
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Charges declared children before decoding them. An oversized container
|
||||
* fails before any child is read. Each visit to a shared container charges
|
||||
* its children again, which bounds pointer fan-out.
|
||||
*/
|
||||
private function enterContainer(
|
||||
int $size,
|
||||
int $depth,
|
||||
int $valuesPerEntry = 1
|
||||
): void {
|
||||
if ($depth >= self::MAX_DEPTH) {
|
||||
throw new InvalidDatabaseException(
|
||||
'The MaxMind DB file exceeds the maximum depth'
|
||||
);
|
||||
}
|
||||
if ($size > intdiv($this->budget, $valuesPerEntry)) {
|
||||
throw new InvalidDatabaseException(
|
||||
'The MaxMind DB file exceeds the maximum number of values'
|
||||
);
|
||||
}
|
||||
$this->budget -= $size * $valuesPerEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{0:array<mixed>, 1:int}
|
||||
*/
|
||||
private function decodeArray(int $size, int $offset): array
|
||||
private function decodeArray(int $size, int $offset, int $depth): array
|
||||
{
|
||||
$this->enterContainer($size, $depth);
|
||||
|
||||
$array = [];
|
||||
|
||||
for ($i = 0; $i < $size; ++$i) {
|
||||
[$value, $offset] = $this->decode($offset);
|
||||
[$value, $offset] = $this->decodeWithBudget($offset, $depth + 1);
|
||||
$array[] = $value;
|
||||
}
|
||||
|
||||
|
|
@ -258,13 +420,16 @@ class Decoder
|
|||
/**
|
||||
* @return array{0:array<string, mixed>, 1:int}
|
||||
*/
|
||||
private function decodeMap(int $size, int $offset): array
|
||||
private function decodeMap(int $size, int $offset, int $depth): array
|
||||
{
|
||||
// A map entry decodes a key and a value, so it costs two values.
|
||||
$this->enterContainer($size, $depth, 2);
|
||||
|
||||
$map = [];
|
||||
|
||||
for ($i = 0; $i < $size; ++$i) {
|
||||
[$key, $offset] = $this->decode($offset);
|
||||
[$value, $offset] = $this->decode($offset);
|
||||
[$key, $offset] = $this->decodeWithBudget($offset, $depth + 1);
|
||||
[$value, $offset] = $this->decodeWithBudget($offset, $depth + 1);
|
||||
$map[$key] = $value;
|
||||
}
|
||||
|
||||
|
|
@ -278,7 +443,7 @@ class Decoder
|
|||
{
|
||||
$pointerSize = (($ctrlByte >> 3) & 0x3) + 1;
|
||||
|
||||
$buffer = Util::read($this->fileStream, $offset, $pointerSize);
|
||||
$buffer = $this->read($offset, $pointerSize);
|
||||
$offset += $pointerSize;
|
||||
|
||||
switch ($pointerSize) {
|
||||
|
|
@ -404,7 +569,7 @@ class Decoder
|
|||
}
|
||||
|
||||
$bytesToRead = $size - 28;
|
||||
$bytes = Util::read($this->fileStream, $offset, $bytesToRead);
|
||||
$bytes = $this->read($offset, $bytesToRead);
|
||||
|
||||
if ($size === 29) {
|
||||
$size = 29 + \ord($bytes);
|
||||
|
|
|
|||
|
|
@ -18,10 +18,8 @@ class Util
|
|||
if (fseek($stream, $offset) === 0) {
|
||||
$value = fread($stream, $numberOfBytes);
|
||||
|
||||
// We check that the number of bytes read is equal to the number
|
||||
// asked for. We use ftell as getting the length of $value is
|
||||
// much slower.
|
||||
if ($value !== false && ftell($stream) - $offset === $numberOfBytes) {
|
||||
// Check that the number of bytes read is the number asked for.
|
||||
if ($value !== false && \strlen($value) === $numberOfBytes) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue