Skip to content

allow to build with system liburiparser #18886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions ext/uri/config.m4
Original file line number Diff line number Diff line change
@@ -1,22 +1,41 @@
dnl Configure options
dnl

PHP_ARG_WITH([external-uriparser],
[for external/system liburiparser],
[AS_HELP_STRING([--with-external-uriparser],
[Use externalsystem liburiparser])],
[no],
[no])

PHP_INSTALL_HEADERS([ext/uri], m4_normalize([
php_lexbor.h
php_uri.h
php_uri_common.h
]))


AC_DEFINE([URI_ENABLE_ANSI], [1], [Define to 1 for enabling ANSI support of uriparser.])
AC_DEFINE([URI_NO_UNICODE], [1], [Define to 1 for disabling unicode support of uriparser.])

URIPARSER_DIR="uriparser"
URIPARSER_SOURCES="$URIPARSER_DIR/src/UriCommon.c $URIPARSER_DIR/src/UriCompare.c $URIPARSER_DIR/src/UriEscape.c \
$URIPARSER_DIR/src/UriFile.c $URIPARSER_DIR/src/UriIp4.c $URIPARSER_DIR/src/UriIp4Base.c \
$URIPARSER_DIR/src/UriMemory.c $URIPARSER_DIR/src/UriNormalize.c $URIPARSER_DIR/src/UriNormalizeBase.c \
$URIPARSER_DIR/src/UriParse.c $URIPARSER_DIR/src/UriParseBase.c $URIPARSER_DIR/src/UriQuery.c \
$URIPARSER_DIR/src/UriRecompose.c $URIPARSER_DIR/src/UriResolve.c $URIPARSER_DIR/src/UriShorten.c"
if test "$PHP_EXTERNAL_URIPARSER" = "no"; then
URIPARSER_DIR="uriparser"
URIPARSER_SOURCES="$URIPARSER_DIR/src/UriCommon.c $URIPARSER_DIR/src/UriCompare.c $URIPARSER_DIR/src/UriEscape.c \
$URIPARSER_DIR/src/UriFile.c $URIPARSER_DIR/src/UriIp4.c $URIPARSER_DIR/src/UriIp4Base.c \
$URIPARSER_DIR/src/UriMemory.c $URIPARSER_DIR/src/UriNormalize.c $URIPARSER_DIR/src/UriNormalizeBase.c \
$URIPARSER_DIR/src/UriParse.c $URIPARSER_DIR/src/UriParseBase.c $URIPARSER_DIR/src/UriQuery.c \
$URIPARSER_DIR/src/UriRecompose.c $URIPARSER_DIR/src/UriResolve.c $URIPARSER_DIR/src/UriShorten.c"
URI_CFLAGS="-DURI_STATIC_BUILD"
else
PKG_CHECK_MODULES([LIBURIPARSER], [liburiparser >= 0.9.8])
Copy link
Member Author

@remicollet remicollet Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the same version than the bundled one (0.9.8 release in May 2024, fixing 2 CVEs)

May be interesting to see if 0.9.7 is OK as this seems to be the version in debian (released in Oct 2022)

ping @oerdnj

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So will have to be 0.9.9 later (in PR #18836)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps also an even later version, since that PR also is not fully implementing the RFC. The "withers" to update an URI are missing and might also require some upstream changes.

PHP_EVAL_LIBLINE([$LIBURIPARSER_LIBS], [URI_SHARED_LIBADD])
PHP_EVAL_INCLINE([$LIBURIPARSER_CFLAGS])
fi

PHP_NEW_EXTENSION(uri, [php_lexbor.c php_uri.c php_uri_common.c $URIPARSER_SOURCES], [no],,[-I$ext_srcdir/$URIPARSER_DIR/include -DURI_STATIC_BUILD -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
PHP_NEW_EXTENSION(uri, [php_lexbor.c php_uri.c php_uri_common.c $URIPARSER_SOURCES], [no],,[$URI_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
PHP_ADD_EXTENSION_DEP(uri, lexbor)
PHP_ADD_BUILD_DIR($ext_builddir/$URIPARSER_DIR/src $ext_builddir/$URIPARSER_DIR/include)

if test "$PHP_EXTERNAL_URIPARSER" = "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/$URIPARSER_DIR/src $ext_builddir/$URIPARSER_DIR/include)
PHP_ADD_INCLUDE([$ext_srcdir/$URIPARSER_DIR/include])
fi
10 changes: 6 additions & 4 deletions ext/uri/php_uri.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "php_uri_common.h"
#include "php_lexbor.h"
#include "php_uri_arginfo.h"
#include "uriparser/src/UriConfig.h"
#include "uriparser/UriBase.h"

zend_class_entry *uri_whatwg_url_ce;
zend_object_handlers uri_whatwg_uri_object_handlers;
Expand All @@ -40,8 +40,6 @@ zend_class_entry *uri_whatwg_invalid_url_exception_ce;
zend_class_entry *uri_whatwg_url_validation_error_type_ce;
zend_class_entry *uri_whatwg_url_validation_error_ce;

#define URIPARSER_VERSION PACKAGE_VERSION

static const zend_module_dep uri_deps[] = {
ZEND_MOD_REQUIRED("lexbor")
ZEND_MOD_END
Expand Down Expand Up @@ -652,7 +650,11 @@ static PHP_MINFO_FUNCTION(uri)
{
php_info_print_table_start();
php_info_print_table_row(2, "uri support", "active");
php_info_print_table_row(2, "uriparser library version", URIPARSER_VERSION);
#ifdef URI_STATIC_BUILD
php_info_print_table_row(2, "uriparser bundled library version", URI_VER_ANSI);
#else
php_info_print_table_row(2, "uriparser system library version", URI_VER_ANSI);
#endif
php_info_print_table_end();
}

Expand Down
Loading