-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add ext/uri skeleton along with uriparser #18658
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
Changes from 1 commit
5044bcf
61c42ab
ac9af23
f3f6d97
908120d
7a819d8
ce047d7
35106c6
19a9f4b
24a8022
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,4 @@ | |
|
||
# Vendored libraries | ||
/ext/lexbor/lexbor linguist-vendored | ||
/ext/uri/uriparser linguist-vendored |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
uri | ||
Máté Kocsis, Tim Düsterhus, Ignace Nyamagana Butera, Arnaud Le Blanc, Niels Dossche, Nicolas Grekas |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
dnl Configure options | ||
dnl | ||
|
||
PHP_INSTALL_HEADERS([ext/uri], m4_normalize([ | ||
php_lexbor.h | ||
TimWolla marked this conversation as resolved.
Show resolved
Hide resolved
|
||
php_uri.h | ||
php_uri_common.h | ||
php_uriparser.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" | ||
|
||
PHP_NEW_EXTENSION(uri, [php_uri.c php_uri_common.c php_lexbor.c php_uriparser.c $URIPARSER_SOURCES], [no],,[-I$ext_builddir/$URIPARSER_DIR/include -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1]) | ||
TimWolla marked this conversation as resolved.
Show resolved
Hide resolved
|
||
PHP_ADD_EXTENSION_DEP(uri, lexbor) | ||
PHP_ADD_BUILD_DIR($ext_builddir/$URIPARSER_DIR/src $ext_builddir/$URIPARSER_DIR/include) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
EXTENSION("uri", "php_lexbor.c php_uri.c php_uri_common.c php_uriparser.c", false /* never shared */, "/I ext/lexbor /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); | ||
|
||
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.") | ||
|
||
ADD_EXTENSION_DEP('uri', 'lexbor'); | ||
ADD_SOURCES("ext/uri/uriparser/src", "UriCommon.c UriCompare.c UriEscape.c UriFile.c UriIp4.c UriIp4Base.c UriMemory.c UriNormalize.c UriNormalizeBase.c UriParse.c UriQuery.c UriRecompose.c UriShorten.c", "lexbor"); | ||
PHP_INSTALL_HEADERS("ext/uri", "php_lexbor.h php_uri.h php_uri_common.h php_uriparser.h uriparser/src uriparser/include"); |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,99 @@ | ||||||||||||||||||||||||||||||||||||||||||||
/* | ||||||||||||||||||||||||||||||||||||||||||||
+----------------------------------------------------------------------+ | ||||||||||||||||||||||||||||||||||||||||||||
| Copyright (c) The PHP Group | | ||||||||||||||||||||||||||||||||||||||||||||
+----------------------------------------------------------------------+ | ||||||||||||||||||||||||||||||||||||||||||||
| This source file is subject to version 3.01 of the PHP license, | | ||||||||||||||||||||||||||||||||||||||||||||
| that is bundled with this package in the file LICENSE, and is | | ||||||||||||||||||||||||||||||||||||||||||||
| available through the world-wide-web at the following url: | | ||||||||||||||||||||||||||||||||||||||||||||
| https://www.php.net/license/3_01.txt | | ||||||||||||||||||||||||||||||||||||||||||||
| If you did not receive a copy of the PHP license and are unable to | | ||||||||||||||||||||||||||||||||||||||||||||
| obtain it through the world-wide-web, please send a note to | | ||||||||||||||||||||||||||||||||||||||||||||
| license@php.net so we can mail you a copy immediately. | | ||||||||||||||||||||||||||||||||||||||||||||
+----------------------------------------------------------------------+ | ||||||||||||||||||||||||||||||||||||||||||||
| Authors: Máté Kocsis <kocsismate@php.net> | | ||||||||||||||||||||||||||||||||||||||||||||
+----------------------------------------------------------------------+ | ||||||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
#ifdef HAVE_CONFIG_H | ||||||||||||||||||||||||||||||||||||||||||||
# include "config.h" | ||||||||||||||||||||||||||||||||||||||||||||
TimWolla marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||
#endif | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
#include "php.h" | ||||||||||||||||||||||||||||||||||||||||||||
#include "Zend/zend_interfaces.h" | ||||||||||||||||||||||||||||||||||||||||||||
#include "Zend/zend_exceptions.h" | ||||||||||||||||||||||||||||||||||||||||||||
#include "Zend/zend_attributes.h" | ||||||||||||||||||||||||||||||||||||||||||||
#include "main/php_ini.h" | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
#include "php_uri.h" | ||||||||||||||||||||||||||||||||||||||||||||
#include "php_uri_arginfo.h" | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
zend_class_entry *uri_exception_ce; | ||||||||||||||||||||||||||||||||||||||||||||
zend_class_entry *invalid_uri_exception_ce; | ||||||||||||||||||||||||||||||||||||||||||||
zend_class_entry *whatwg_invalid_url_exception_ce; | ||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+32
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are not currently exported, but exporting the exception CEs might make sense. I suggest to rename them to avoid conflicts. The following pattern is used by ext/random:
Suggested change
see Lines 58 to 72 in c7db07e
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make renames a bit later when the actual content is also added - at least I can then use the IDE to also rename the references. 🤔 |
||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
#define URIPARSER_VERSION "0.9.8" | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
static const zend_module_dep uri_deps[] = { | ||||||||||||||||||||||||||||||||||||||||||||
ZEND_MOD_REQUIRED("lexbor") | ||||||||||||||||||||||||||||||||||||||||||||
ZEND_MOD_END | ||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
static PHP_MINIT_FUNCTION(uri) | ||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||
uri_exception_ce = register_class_Uri_UriException(zend_ce_exception); | ||||||||||||||||||||||||||||||||||||||||||||
invalid_uri_exception_ce = register_class_Uri_InvalidUriException(uri_exception_ce); | ||||||||||||||||||||||||||||||||||||||||||||
whatwg_invalid_url_exception_ce = register_class_Uri_WhatWg_InvalidUrlException(invalid_uri_exception_ce); | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
return SUCCESS; | ||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
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 version", URIPARSER_VERSION); | ||||||||||||||||||||||||||||||||||||||||||||
TimWolla marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||
php_info_print_table_end(); | ||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
static PHP_MSHUTDOWN_FUNCTION(uri) | ||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||
UNREGISTER_INI_ENTRIES(); | ||||||||||||||||||||||||||||||||||||||||||||
TimWolla marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
return SUCCESS; | ||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
PHP_RINIT_FUNCTION(uri) | ||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||
#if defined(COMPILE_DL_URI) && defined(ZTS) | ||||||||||||||||||||||||||||||||||||||||||||
ZEND_TSRMLS_CACHE_UPDATE(); | ||||||||||||||||||||||||||||||||||||||||||||
#endif | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
TimWolla marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||
return SUCCESS; | ||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
PHP_RSHUTDOWN_FUNCTION(uri) | ||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||
return SUCCESS; | ||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
zend_module_entry uri_module_entry = { | ||||||||||||||||||||||||||||||||||||||||||||
STANDARD_MODULE_HEADER_EX, NULL, | ||||||||||||||||||||||||||||||||||||||||||||
uri_deps, | ||||||||||||||||||||||||||||||||||||||||||||
"uri", /* Extension name */ | ||||||||||||||||||||||||||||||||||||||||||||
NULL, /* zend_function_entry */ | ||||||||||||||||||||||||||||||||||||||||||||
PHP_MINIT(uri), /* PHP_MINIT - Module initialization */ | ||||||||||||||||||||||||||||||||||||||||||||
PHP_MSHUTDOWN(uri), /* PHP_MSHUTDOWN - Module shutdown */ | ||||||||||||||||||||||||||||||||||||||||||||
PHP_RINIT(uri), /* PHP_RINIT - Request initialization */ | ||||||||||||||||||||||||||||||||||||||||||||
PHP_RSHUTDOWN(uri), /* PHP_RSHUTDOWN - Request shutdown */ | ||||||||||||||||||||||||||||||||||||||||||||
PHP_MINFO(uri), /* PHP_MINFO - Module info */ | ||||||||||||||||||||||||||||||||||||||||||||
PHP_VERSION, /* Version */ | ||||||||||||||||||||||||||||||||||||||||||||
STANDARD_MODULE_PROPERTIES | ||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
#ifdef COMPILE_DL_URI | ||||||||||||||||||||||||||||||||||||||||||||
#ifdef ZTS | ||||||||||||||||||||||||||||||||||||||||||||
ZEND_TSRMLS_CACHE_DEFINE() | ||||||||||||||||||||||||||||||||||||||||||||
#endif | ||||||||||||||||||||||||||||||||||||||||||||
ZEND_GET_MODULE(uri) | ||||||||||||||||||||||||||||||||||||||||||||
#endif | ||||||||||||||||||||||||||||||||||||||||||||
TimWolla marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
+----------------------------------------------------------------------+ | ||
| Copyright (c) The PHP Group | | ||
+----------------------------------------------------------------------+ | ||
| This source file is subject to version 3.01 of the PHP license, | | ||
| that is bundled with this package in the file LICENSE, and is | | ||
| available through the world-wide-web at the following url: | | ||
| https://www.php.net/license/3_01.txt | | ||
| If you did not receive a copy of the PHP license and are unable to | | ||
| obtain it through the world-wide-web, please send a note to | | ||
| license@php.net so we can mail you a copy immediately. | | ||
+----------------------------------------------------------------------+ | ||
| Authors: Máté Kocsis <kocsismate@php.net> | | ||
+----------------------------------------------------------------------+ | ||
*/ | ||
|
||
#ifndef PHP_URI_H | ||
#define PHP_URI_H | ||
|
||
extern zend_module_entry uri_module_entry; | ||
#define phpext_uri_ptr &uri_module_entry | ||
|
||
#if defined(ZTS) && defined(COMPILE_DL_URI) | ||
ZEND_TSRMLS_CACHE_EXTERN() | ||
#endif | ||
TimWolla marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
/** @generate-class-entries */ | ||
|
||
namespace Uri { | ||
/** @strict-properties */ | ||
class UriException extends \Exception | ||
{ | ||
} | ||
|
||
/** @strict-properties */ | ||
class InvalidUriException extends \Uri\UriException | ||
{ | ||
} | ||
} | ||
|
||
namespace Uri\WhatWg { | ||
/** @strict-properties */ | ||
class InvalidUrlException extends \Uri\InvalidUriException | ||
{ | ||
public readonly array $errors; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
uriparser - RFC 3986 URI parsing library | ||
|
||
Copyright (C) 2007, Weijia Song <songweijia@gmail.com> | ||
Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
|
||
1. Redistributions of source code must retain the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials | ||
provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of | ||
its contributors may be used to endorse or promote products | ||
derived from this software without specific prior written | ||
permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
OF THE POSSIBILITY OF SUCH DAMAGE. |
Uh oh!
There was an error while loading. Please reload this page.