From 62e9d3e1f5ec8896131313c70574ce7f7cbcfc99 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 29 Oct 2014 08:54:49 +0100 Subject: [PATCH] update --- gen_curlinfo.php | 0 ctype.php => gen_utf8.php | 21 +-- package.xml | 10 +- php_http_url.c | 126 +++-------------- ualpha.h => php_http_utf8.h | 122 +++++++++++++++- tests/urlparser001.phpt | 191 +++++++++++++++++++++++++ tests/urlparser002.phpt | 211 +++++++++++++++++++++++++++ tests/urlparser003.phpt | 274 ++++++++++++++++++++++++++++++++++++ tests/urlparser004.phpt | 89 ++++++++++++ tests/urlparser005.phpt | 85 +++++++++++ tests/urlparser006.phpt | 90 ++++++++++++ tests/urlparser007.phpt | 88 ++++++++++++ 12 files changed, 1179 insertions(+), 128 deletions(-) mode change 100644 => 100755 gen_curlinfo.php rename ctype.php => gen_utf8.php (87%) mode change 100644 => 100755 rename ualpha.h => php_http_utf8.h (86%) create mode 100644 tests/urlparser001.phpt create mode 100644 tests/urlparser002.phpt create mode 100644 tests/urlparser003.phpt create mode 100644 tests/urlparser004.phpt create mode 100644 tests/urlparser005.phpt create mode 100644 tests/urlparser006.phpt create mode 100644 tests/urlparser007.phpt diff --git a/gen_curlinfo.php b/gen_curlinfo.php old mode 100644 new mode 100755 diff --git a/ctype.php b/gen_utf8.php old mode 100644 new mode 100755 similarity index 87% rename from ctype.php rename to gen_utf8.php index c670096..2675f15 --- a/ctype.php +++ b/gen_utf8.php @@ -1,3 +1,4 @@ +#!/usr/bin/env php = 2 ? $argv[1] : "/usr/share/i18n/locales/i18n"; $f = fopen($i18n, "r"); $c = false; $a = false; -$r = array(); -print << + @@ -272,11 +273,18 @@ v2: http://dev.iworks.at/ext-http/lcov/ext/http/ + - + + + + + + + diff --git a/php_http_url.c b/php_http_url.c index 2bf40b7..5ace03d 100644 --- a/php_http_url.c +++ b/php_http_url.c @@ -21,6 +21,8 @@ # include #endif +#include "php_http_utf8.h" + static inline char *localhostname(void) { char hostname[1024] = {0}; @@ -328,93 +330,6 @@ void php_http_url_free(php_http_url_t **url) } } -static const unsigned char utf8mblen[256] = { - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, - 4,4,4,4,4,4,4,4,5,5,5,5,6,6,6,6 -}; -static const unsigned char utf8mask[] = { - 0, 0x7f, 0x1f, 0x0f, 0x07, 0x03, 0x01 -}; - -static inline size_t utf8towc(unsigned *wc, const unsigned char *uc, size_t len) -{ - unsigned char ub = utf8mblen[*uc]; - - if (!ub || ub > len || ub > 3) { - return 0; - } - - *wc = *uc & utf8mask[ub]; - - switch (ub) { - case 4: - if ((uc[1] & 0xc0) != 0x80) { - return 0; - } - *wc <<= 6; - *wc += *++uc & 0x3f; - /* no break */ - case 3: - if ((uc[1] & 0xc0) != 0x80) { - return 0; - } - *wc <<= 6; - *wc += *++uc & 0x3f; - /* no break */ - case 2: - if ((uc[1] & 0xc0) != 0x80) { - return 0; - } - *wc <<= 6; - *wc += *++uc & 0x3f; - break; - - default: - return 0; - } - - return ub; -} - -#include "ualpha.h" - -static inline zend_bool isualnum(unsigned ch) -{ - unsigned i; - - /* digits */ - if (ch >= 0x30 && ch <= 0x39) { - return 1; - } - - for (i = 0; i < sizeof(utf8_ranges)/sizeof(utf8_range_t); ++i) { - if (utf8_ranges[i].start == ch) { - return 1; - } else if (utf8_ranges[i].start <= ch && utf8_ranges[i].end >= ch) { - if (utf8_ranges[i].step == 1) { - return 1; - } - /* FIXME step */ - return 0; - } - } - return 0; -} - static size_t parse_mb_utf8(php_http_url_t *url, const char *ptr, const char *end, zend_bool idn) { unsigned wchar; @@ -646,35 +561,26 @@ static STATUS parse_hostinfo(php_http_url_t *url, const char *ptr, const char *e #ifdef PHP_HTTP_HAVE_IDN if (url->flags & PHP_HTTP_URL_PARSE_IDN) { - if (url->flags & PHP_HTTP_URL_PARSE_MBUTF8) { - char *idn = NULL; - int rv = idna_to_ascii_8z(url->authority.host.str, &idn, IDNA_ALLOW_UNASSIGNED|IDNA_USE_STD3_ASCII_RULES); + char *idn = NULL; + int rv = -1; - if (rv != IDNA_SUCCESS) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to parse IDN; %s", idna_strerror(rv)); - return FAILURE; - } else { - STR_SET(url->authority.host.str, estrdup(idn)); - url->authority.host.len = strlen(idn); - free(idn); - } + if (url->flags & PHP_HTTP_URL_PARSE_MBUTF8) { + rv = idna_to_ascii_8z(url->authority.host.str, &idn, IDNA_ALLOW_UNASSIGNED|IDNA_USE_STD3_ASCII_RULES); } # ifdef PHP_HTTP_HAVE_WCHAR else if (url->flags & PHP_HTTP_URL_PARSE_MBLOC) { - char *idn = NULL; - int rv = idna_to_ascii_lz(url->authority.host.str, &idn, IDNA_ALLOW_UNASSIGNED|IDNA_USE_STD3_ASCII_RULES); - - if (rv != IDNA_SUCCESS) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to parse IDN; %s", idna_strerror(rv)); - return FAILURE; - } else { - STR_SET(url->authority.host.str, estrdup(idn)); - url->authority.host.len = strlen(idn); - free(idn); - } + rv = idna_to_ascii_lz(url->authority.host.str, &idn, IDNA_ALLOW_UNASSIGNED|IDNA_USE_STD3_ASCII_RULES); } - } # endif + if (rv != IDNA_SUCCESS) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to parse IDN; %s", idna_strerror(rv)); + return FAILURE; + } else { + STR_SET(url->authority.host.str, estrdup(idn)); + url->authority.host.len = strlen(idn); + free(idn); + } + } #endif return SUCCESS; diff --git a/ualpha.h b/php_http_utf8.h similarity index 86% rename from ualpha.h rename to php_http_utf8.h index 688777d..b9b7b28 100644 --- a/ualpha.h +++ b/php_http_utf8.h @@ -1,10 +1,49 @@ +/* + +--------------------------------------------------------------------+ + | PECL :: http | + +--------------------------------------------------------------------+ + | Redistribution and use in source and binary forms, with or without | + | modification, are permitted provided that the conditions mentioned | + | in the accompanying LICENSE file are met. | + +--------------------------------------------------------------------+ + | Copyright (c) 2004-2014, Michael Wallner | + +--------------------------------------------------------------------+ +*/ + +#ifndef PHP_HTTP_UTF8_H +#define PHP_HTTP_UTF8_H + typedef struct utf8_range { unsigned int start; unsigned int end; unsigned char step; } utf8_range_t; +static const unsigned char utf8_mblen[256] = { + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, + 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, + 4,4,4,4,4,4,4,4,5,5,5,5,6,6,6,6 +}; + +static const unsigned char utf8_mask[] = { + 0, 0x7f, 0x1f, 0x0f, 0x07, 0x03, 0x01 +}; + static const utf8_range_t utf8_ranges[] = { +/* BEGIN::UTF8TABLE */ /* BASIC LATIN */ { 0x0041, 0x005A, 1}, { 0x0061, 0x007A, 1}, @@ -650,5 +689,86 @@ static const utf8_range_t utf8_ranges[] = { { 0xAA50, 0xAA59, 1}, /* HALFWIDTH AND FULLWIDTH FORMS */ { 0xFF10, 0xFF19, 1}, - {0, 0, 0} + +/* END::UTF8TABLE */ }; + +static inline size_t utf8towc(unsigned *wc, const unsigned char *uc, size_t len) +{ + unsigned char ub = utf8_mblen[*uc]; + + if (!ub || ub > len || ub > 3) { + return 0; + } + + *wc = *uc & utf8_mask[ub]; + + switch (ub) { + case 4: + if ((uc[1] & 0xc0) != 0x80) { + return 0; + } + *wc <<= 6; + *wc += *++uc & 0x3f; + /* no break */ + case 3: + if ((uc[1] & 0xc0) != 0x80) { + return 0; + } + *wc <<= 6; + *wc += *++uc & 0x3f; + /* no break */ + case 2: + if ((uc[1] & 0xc0) != 0x80) { + return 0; + } + *wc <<= 6; + *wc += *++uc & 0x3f; + /* no break */ + case 1: + break; + + default: + return 0; + } + + return ub; +} + +static inline zend_bool isualpha(unsigned ch) +{ + unsigned i; + + for (i = 0; i < sizeof(utf8_ranges)/sizeof(utf8_range_t); ++i) { + if (utf8_ranges[i].start == ch) { + return 1; + } else if (utf8_ranges[i].start <= ch && utf8_ranges[i].end >= ch) { + if (utf8_ranges[i].step == 1) { + return 1; + } + /* FIXME step */ + return 0; + } + } + return 0; +} + +static inline zend_bool isualnum(unsigned ch) +{ + /* digits */ + if (ch >= 0x30 && ch <= 0x39) { + return 1; + } + return isualpha(ch); +} + +#endif /* PHP_HTTP_UTF8_H */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/tests/urlparser001.phpt b/tests/urlparser001.phpt new file mode 100644 index 0000000..73bd9d4 --- /dev/null +++ b/tests/urlparser001.phpt @@ -0,0 +1,191 @@ +--TEST-- +url parser +--SKIPIF-- + +--FILE-- + +DONE +--EXPECTF-- +Test + +s: +object(http\Url)#%d (8) { + ["scheme"]=> + string(1) "s" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + NULL + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +ss: +object(http\Url)#%d (8) { + ["scheme"]=> + string(2) "ss" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + NULL + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +s:a +object(http\Url)#%d (8) { + ["scheme"]=> + string(1) "s" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + string(1) "a" + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +ss:aa +object(http\Url)#%d (8) { + ["scheme"]=> + string(2) "ss" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + string(2) "aa" + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +s:// +object(http\Url)#%d (8) { + ["scheme"]=> + string(1) "s" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + NULL + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +ss:// +object(http\Url)#%d (8) { + ["scheme"]=> + string(2) "ss" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + NULL + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +s://a +object(http\Url)#%d (8) { + ["scheme"]=> + string(1) "s" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + string(1) "a" + ["port"]=> + NULL + ["path"]=> + NULL + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +ss://aa +object(http\Url)#%d (8) { + ["scheme"]=> + string(2) "ss" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + string(2) "aa" + ["port"]=> + NULL + ["path"]=> + NULL + ["query"]=> + NULL + ["fragment"]=> + NULL +} +DONE diff --git a/tests/urlparser002.phpt b/tests/urlparser002.phpt new file mode 100644 index 0000000..be1cd66 --- /dev/null +++ b/tests/urlparser002.phpt @@ -0,0 +1,211 @@ +--TEST-- +url parser with paths +--SKIPIF-- + +--FILE-- + +DONE +--EXPECTF-- +Test + +s:a/ +object(http\Url)#%d (8) { + ["scheme"]=> + string(1) "s" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + string(2) "a/" + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +ss:aa/ +object(http\Url)#%d (8) { + ["scheme"]=> + string(2) "ss" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + string(3) "aa/" + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +s:/a/ +object(http\Url)#%d (8) { + ["scheme"]=> + string(1) "s" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + string(3) "/a/" + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +ss:/aa/ +object(http\Url)#%d (8) { + ["scheme"]=> + string(2) "ss" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + string(4) "/aa/" + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +s://a/ +object(http\Url)#%d (8) { + ["scheme"]=> + string(1) "s" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + string(1) "a" + ["port"]=> + NULL + ["path"]=> + string(1) "/" + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +s://h/a +object(http\Url)#%d (8) { + ["scheme"]=> + string(1) "s" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + string(1) "h" + ["port"]=> + NULL + ["path"]=> + string(2) "/a" + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +ss://hh/aa +object(http\Url)#%d (8) { + ["scheme"]=> + string(2) "ss" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + string(2) "hh" + ["port"]=> + NULL + ["path"]=> + string(3) "/aa" + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +s:///a/b +object(http\Url)#%d (8) { + ["scheme"]=> + string(1) "s" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + string(4) "/a/b" + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +ss:///aa/bb +object(http\Url)#%d (8) { + ["scheme"]=> + string(2) "ss" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + string(6) "/aa/bb" + ["query"]=> + NULL + ["fragment"]=> + NULL +} +DONE diff --git a/tests/urlparser003.phpt b/tests/urlparser003.phpt new file mode 100644 index 0000000..68b1e4a --- /dev/null +++ b/tests/urlparser003.phpt @@ -0,0 +1,274 @@ +--TEST-- +url parser with query +--SKIPIF-- + +--FILE-- + +DONE +--EXPECTF-- +Test + +s:?q +object(http\Url)#%d (8) { + ["scheme"]=> + string(1) "s" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + NULL + ["query"]=> + string(1) "q" + ["fragment"]=> + NULL +} + +ss:?qq +object(http\Url)#%d (8) { + ["scheme"]=> + string(2) "ss" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + NULL + ["query"]=> + string(2) "qq" + ["fragment"]=> + NULL +} + +s:/?q +object(http\Url)#%d (8) { + ["scheme"]=> + string(1) "s" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + string(1) "/" + ["query"]=> + string(1) "q" + ["fragment"]=> + NULL +} + +ss:/?qq +object(http\Url)#%d (8) { + ["scheme"]=> + string(2) "ss" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + string(1) "/" + ["query"]=> + string(2) "qq" + ["fragment"]=> + NULL +} + +s://?q +object(http\Url)#%d (8) { + ["scheme"]=> + string(1) "s" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + NULL + ["query"]=> + string(1) "q" + ["fragment"]=> + NULL +} + +ss://?qq +object(http\Url)#%d (8) { + ["scheme"]=> + string(2) "ss" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + NULL + ["query"]=> + string(2) "qq" + ["fragment"]=> + NULL +} + +s://h?q +object(http\Url)#%d (8) { + ["scheme"]=> + string(1) "s" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + string(1) "h" + ["port"]=> + NULL + ["path"]=> + NULL + ["query"]=> + string(1) "q" + ["fragment"]=> + NULL +} + +ss://hh?qq +object(http\Url)#%d (8) { + ["scheme"]=> + string(2) "ss" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + string(2) "hh" + ["port"]=> + NULL + ["path"]=> + NULL + ["query"]=> + string(2) "qq" + ["fragment"]=> + NULL +} + +s://h/p?q +object(http\Url)#%d (8) { + ["scheme"]=> + string(1) "s" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + string(1) "h" + ["port"]=> + NULL + ["path"]=> + string(2) "/p" + ["query"]=> + string(1) "q" + ["fragment"]=> + NULL +} + +ss://hh/pp?qq +object(http\Url)#%d (8) { + ["scheme"]=> + string(2) "ss" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + string(2) "hh" + ["port"]=> + NULL + ["path"]=> + string(3) "/pp" + ["query"]=> + string(2) "qq" + ["fragment"]=> + NULL +} + +s://h:123/p/?q +object(http\Url)#%d (8) { + ["scheme"]=> + string(1) "s" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + string(1) "h" + ["port"]=> + int(123) + ["path"]=> + string(3) "/p/" + ["query"]=> + string(1) "q" + ["fragment"]=> + NULL +} + +ss://hh:123/pp/?qq +object(http\Url)#%d (8) { + ["scheme"]=> + string(2) "ss" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + string(2) "hh" + ["port"]=> + int(123) + ["path"]=> + string(4) "/pp/" + ["query"]=> + string(2) "qq" + ["fragment"]=> + NULL +} +DONE diff --git a/tests/urlparser004.phpt b/tests/urlparser004.phpt new file mode 100644 index 0000000..3aa57fd --- /dev/null +++ b/tests/urlparser004.phpt @@ -0,0 +1,89 @@ +--TEST-- +url parser multibyte/locale +--SKIPIF-- + +--FILE-- + +DONE +--EXPECTF-- +Test + +sçheme: +object(http\Url)#%d (8) { + ["scheme"]=> + string(7) "sçheme" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + NULL + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +sçheme://hƟst +object(http\Url)#%d (8) { + ["scheme"]=> + string(7) "sçheme" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + string(5) "hƟst" + ["port"]=> + NULL + ["path"]=> + NULL + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +sçheme://hƟst:23/päth/öf/fıle +object(http\Url)#%d (8) { + ["scheme"]=> + string(7) "sçheme" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + string(5) "hƟst" + ["port"]=> + int(23) + ["path"]=> + string(16) "/päth/öf/fıle" + ["query"]=> + NULL + ["fragment"]=> + NULL +} +DONE diff --git a/tests/urlparser005.phpt b/tests/urlparser005.phpt new file mode 100644 index 0000000..ff18fe4 --- /dev/null +++ b/tests/urlparser005.phpt @@ -0,0 +1,85 @@ +--TEST-- +url parser multibyte/utf-8 +--SKIPIF-- + +--FILE-- + +DONE +--EXPECTF-- +Test + +sçheme: +object(http\Url)#%d (8) { + ["scheme"]=> + string(7) "sçheme" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + NULL + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +sçheme://hƟst +object(http\Url)#%d (8) { + ["scheme"]=> + string(7) "sçheme" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + string(5) "hƟst" + ["port"]=> + NULL + ["path"]=> + NULL + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +sçheme://hƟst:23/päth/öf/fıle +object(http\Url)#%d (8) { + ["scheme"]=> + string(7) "sçheme" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + string(5) "hƟst" + ["port"]=> + int(23) + ["path"]=> + string(16) "/päth/öf/fıle" + ["query"]=> + NULL + ["fragment"]=> + NULL +} +DONE diff --git a/tests/urlparser006.phpt b/tests/urlparser006.phpt new file mode 100644 index 0000000..c35a20f --- /dev/null +++ b/tests/urlparser006.phpt @@ -0,0 +1,90 @@ +--TEST-- +url parser multibyte/locale/idna +--SKIPIF-- + +--FILE-- + +DONE +--EXPECTF-- +Test + +sçheme: +object(http\Url)#%d (8) { + ["scheme"]=> + string(7) "sçheme" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + NULL + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +sçheme://hƟst +object(http\Url)#%d (8) { + ["scheme"]=> + string(7) "sçheme" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + string(11) "xn--hst-kwb" + ["port"]=> + NULL + ["path"]=> + NULL + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +sçheme://hƟst:23/päth/öf/fıle +object(http\Url)#%d (8) { + ["scheme"]=> + string(7) "sçheme" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + string(11) "xn--hst-kwb" + ["port"]=> + int(23) + ["path"]=> + string(16) "/päth/öf/fıle" + ["query"]=> + NULL + ["fragment"]=> + NULL +} +DONE diff --git a/tests/urlparser007.phpt b/tests/urlparser007.phpt new file mode 100644 index 0000000..702302b --- /dev/null +++ b/tests/urlparser007.phpt @@ -0,0 +1,88 @@ +--TEST-- +url parser multibyte/utf-8/idna +--SKIPIF-- + +--FILE-- + +DONE +--EXPECTF-- +Test + +sçheme: +object(http\Url)#%d (8) { + ["scheme"]=> + string(7) "sçheme" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + NULL + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +sçheme://hƟst +object(http\Url)#%d (8) { + ["scheme"]=> + string(7) "sçheme" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + string(11) "xn--hst-kwb" + ["port"]=> + NULL + ["path"]=> + NULL + ["query"]=> + NULL + ["fragment"]=> + NULL +} + +sçheme://hƟst:23/päth/öf/fıle +object(http\Url)#%d (8) { + ["scheme"]=> + string(7) "sçheme" + ["user"]=> + NULL + ["pass"]=> + NULL + ["host"]=> + string(11) "xn--hst-kwb" + ["port"]=> + int(23) + ["path"]=> + string(16) "/päth/öf/fıle" + ["query"]=> + NULL + ["fragment"]=> + NULL +} +DONE -- 2.30.2