-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5044bcf
Add ext/uri skeleton along with uriparser
kocsismate 61c42ab
Review fixes
kocsismate ac9af23
Additional review fixes + uriparser sync with latest master
kocsismate f3f6d97
Regenerate credits + remove unused files + fix build
kocsismate 908120d
Add back UriConfig.h
kocsismate 7a819d8
Add URIPARSER_VERSION
kocsismate ce047d7
Add uriparser includes
kocsismate 35106c6
Try to fix Windows build
kocsismate 19a9f4b
One last Windows fix
kocsismate 24a8022
Fix URI compile flag
kocsismate File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ ignore: | |
- "ext/lexbor/lexbor/ports" | ||
- "ext/lexbor/lexbor/tag" | ||
- "ext/pcre/pcre2lib" | ||
- "ext/uri/uriparser" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, Dennis Snell, Niels Dossche, Nicolas Grekas |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
dnl Configure options | ||
dnl | ||
|
||
PHP_INSTALL_HEADERS([ext/uri], m4_normalize([ | ||
php_uri.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 $URIPARSER_SOURCES], [no],,[-I$ext_builddir/$URIPARSER_DIR/include -DURI_STATIC_BUILD -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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
EXTENSION("uri", "php_uri.c", false /* never shared */, "/I ext/lexbor /I ext/uri/uriparser/include /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_FLAG("CFLAGS_URI", "/D URI_STATIC_BUILD"); | ||
|
||
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 UriParseBase.c UriQuery.c UriRecompose.c UriShorten.c", "uri"); | ||
PHP_INSTALL_HEADERS("ext/uri", "php_uri.h uriparser/src uriparser/include"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
+----------------------------------------------------------------------+ | ||
| 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> | ||
#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 "ext/standard/info.h" | ||
|
||
#include "php_uri.h" | ||
#include "php_uri_arginfo.h" | ||
#include "uriparser/src/UriConfig.h" | ||
|
||
zend_class_entry *uri_exception_ce; | ||
zend_class_entry *invalid_uri_exception_ce; | ||
zend_class_entry *whatwg_invalid_url_exception_ce; | ||
|
||
#define URIPARSER_VERSION PACKAGE_VERSION | ||
|
||
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 library version", URIPARSER_VERSION); | ||
php_info_print_table_end(); | ||
} | ||
|
||
static PHP_MSHUTDOWN_FUNCTION(uri) | ||
{ | ||
|
||
return SUCCESS; | ||
} | ||
|
||
PHP_RINIT_FUNCTION(uri) | ||
{ | ||
|
||
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 | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
+----------------------------------------------------------------------+ | ||
| 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 | ||
|
||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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:
see
php-src/ext/random/random.c
Lines 58 to 72 in c7db07e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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. 🤔