projects
/
m6w6
/
ext-http
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
fix edge cases with @
[m6w6/ext-http]
/
php_http_url.c
diff --git
a/php_http_url.c
b/php_http_url.c
index 23dec9f1968aa9b9964ed9339742dd92ecd9377a..1f06271f9527183f12c9c5c2a46506b14a674b74 100644
(file)
--- a/
php_http_url.c
+++ b/
php_http_url.c
@@
-384,7
+384,7
@@
static const char parse_xdigits[] = "0123456789ABCDEF";
static size_t parse_mb(php_http_url_t *url, parse_mb_what_t what, const char *ptr, const char *end, const char *begin, zend_bool silent)
{
size_t consumed = 0;
static size_t parse_mb(php_http_url_t *url, parse_mb_what_t what, const char *ptr, const char *end, const char *begin, zend_bool silent)
{
size_t consumed = 0;
- zend_bool idn = (what == PARSE_HOSTINFO) && (url->flags & PHP_HTTP_URL_PARSE_IDN);
+ zend_bool idn = (what == PARSE_HOSTINFO) && (url->flags & PHP_HTTP_URL_PARSE_
TO
IDN);
if (url->flags & PHP_HTTP_URL_PARSE_MBUTF8) {
consumed = parse_mb_utf8(url, ptr, end, idn);
if (url->flags & PHP_HTTP_URL_PARSE_MBUTF8) {
consumed = parse_mb_utf8(url, ptr, end, idn);
@@
-396,7
+396,7
@@
static size_t parse_mb(php_http_url_t *url, parse_mb_what_t what, const char *pt
#endif
if (consumed) {
#endif
if (consumed) {
- if (!(url->flags & PHP_HTTP_URL_PARSE_
PCTENC
) || what == PARSE_HOSTINFO || what == PARSE_SCHEME) {
+ if (!(url->flags & PHP_HTTP_URL_PARSE_
TOPCT
) || what == PARSE_HOSTINFO || what == PARSE_SCHEME) {
PHP_HTTP_DUFF(consumed, url->buffer[url->offset++] = *ptr++);
} else {
int i = 0;
PHP_HTTP_DUFF(consumed, url->buffer[url->offset++] = *ptr++);
} else {
int i = 0;
@@
-528,7
+528,7
@@
static STATUS parse_hostinfo(php_http_url_t *url, const char *ptr)
case ':':
if (port) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
case ':':
if (port) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
- "Failed to parse port;
duplicate
':' at pos %u in '%s'",
+ "Failed to parse port;
unexpected
':' at pos %u in '%s'",
(unsigned) (ptr - tmp), tmp);
return FAILURE;
}
(unsigned) (ptr - tmp), tmp);
return FAILURE;
}
@@
-596,7
+596,7
@@
static STATUS parse_hostinfo(php_http_url_t *url, const char *ptr)
}
#ifdef PHP_HTTP_HAVE_IDN
}
#ifdef PHP_HTTP_HAVE_IDN
- if (url->flags & PHP_HTTP_URL_PARSE_IDN) {
+ if (url->flags & PHP_HTTP_URL_PARSE_
TO
IDN) {
char *idn = NULL;
int rv = -1;
char *idn = NULL;
int rv = -1;
@@
-625,12
+625,19
@@
static STATUS parse_hostinfo(php_http_url_t *url, const char *ptr)
static const char *parse_authority(php_http_url_t *url)
{
static const char *parse_authority(php_http_url_t *url)
{
- const char *tmp = url->ptr;
+ const char *tmp = url->ptr
, *host = NULL
;
do {
switch (*url->ptr) {
case '@':
/* userinfo delimiter */
do {
switch (*url->ptr) {
case '@':
/* userinfo delimiter */
+ if (host) {
+ TSRMLS_FETCH_FROM_CTX(url->ts);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,
+ "Failed to parse userinfo; unexpected '@'");
+ return NULL;
+ }
+ host = url->ptr + 1;
if (tmp != url->ptr && SUCCESS != parse_userinfo(url, tmp)) {
return NULL;
}
if (tmp != url->ptr && SUCCESS != parse_userinfo(url, tmp)) {
return NULL;
}
@@
-726,8
+733,8
@@
static const char *parse_query(php_http_url_t *url)
const char *tmp = url->ptr + !!*url->ptr;
TSRMLS_FETCH_FROM_CTX(url->ts);
const char *tmp = url->ptr + !!*url->ptr;
TSRMLS_FETCH_FROM_CTX(url->ts);
- /* is there actually a query to parse
? */
- if (
!*url->ptr &&
*url->ptr != '?') {
+ /* is there actually a query to parse? */
+ if (*url->ptr != '?') {
return url->ptr;
}
return url->ptr;
}
@@
-790,8
+797,8
@@
static const char *parse_fragment(php_http_url_t *url)
const char *tmp;
TSRMLS_FETCH_FROM_CTX(url->ts);
const char *tmp;
TSRMLS_FETCH_FROM_CTX(url->ts);
- /* is there actually a fragment to parse */
- if (
!*url->ptr &&
*url->ptr != '#') {
+ /* is there actually a fragment to parse
?
*/
+ if (*url->ptr != '#') {
return url->ptr;
}
return url->ptr;
}
@@
-1209,9
+1216,9
@@
PHP_MINIT_FUNCTION(http_url)
#endif
zend_declare_class_constant_long(php_http_url_class_entry, ZEND_STRL("PARSE_MBUTF8"), PHP_HTTP_URL_PARSE_MBUTF8 TSRMLS_CC);
#ifdef PHP_HTTP_HAVE_IDN
#endif
zend_declare_class_constant_long(php_http_url_class_entry, ZEND_STRL("PARSE_MBUTF8"), PHP_HTTP_URL_PARSE_MBUTF8 TSRMLS_CC);
#ifdef PHP_HTTP_HAVE_IDN
- zend_declare_class_constant_long(php_http_url_class_entry, ZEND_STRL("PARSE_
IDN"), PHP_HTTP_URL_PARSE_
IDN TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_url_class_entry, ZEND_STRL("PARSE_
TOIDN"), PHP_HTTP_URL_PARSE_TO
IDN TSRMLS_CC);
#endif
#endif
- zend_declare_class_constant_long(php_http_url_class_entry, ZEND_STRL("PARSE_
PCTENC"), PHP_HTTP_URL_PARSE_PCTENC
TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_url_class_entry, ZEND_STRL("PARSE_
TOPCT"), PHP_HTTP_URL_PARSE_TOPCT
TSRMLS_CC);
return SUCCESS;
}
return SUCCESS;
}