From: Michael Wallner Date: Wed, 1 Jun 2016 07:28:08 +0000 (+0200) Subject: Allow IDNA/punycode hosts X-Git-Tag: RELEASE_2_6_0_BETA1~20 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=27d02824457cb9ccbb23b021f79957540bda7802;p=m6w6%2Fext-http Allow IDNA/punycode hosts Closes #42 --- diff --git a/src/php_http_url.c b/src/php_http_url.c index 07121df..9140c68 100644 --- a/src/php_http_url.c +++ b/src/php_http_url.c @@ -1095,9 +1095,7 @@ static ZEND_RESULT_CODE parse_hostinfo(struct parse_state *state, const char *pt state->buffer[state->offset++] = *ptr; break; - case '!': case '$': case '&': case '\'': case '(': case ')': case '*': - case '+': case ',': case ';': case '=': /* sub-delims */ - case '-': case '.': case '_': case '~': /* unreserved */ + case '.': if (port || !label) { /* sort of a compromise, just ensure we don't end up * with a dot at the beginning or two consecutive dots @@ -1112,6 +1110,21 @@ static ZEND_RESULT_CODE parse_hostinfo(struct parse_state *state, const char *pt label = NULL; break; + case '-': + if (!label) { + /* sort of a compromise, just ensure we don't end up + * with a hyphen at the beginning + */ + php_error_docref(NULL TSRMLS_CC, E_WARNING, + "Failed to parse %s; unexpected '%c' at pos %u in '%s'", + port ? "port" : "host", + (unsigned char) *ptr, (unsigned) (ptr - tmp), tmp); + return FAILURE; + } + /* no break */ + case '_': case '~': /* unreserved */ + case '!': case '$': case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case ';': case '=': /* sub-delims */ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': diff --git a/tests/gh-issue42.phpt b/tests/gh-issue42.phpt new file mode 100644 index 0000000..a6f9ded --- /dev/null +++ b/tests/gh-issue42.phpt @@ -0,0 +1,16 @@ +--TEST-- +URL barfs on punycode +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +Test +http://www.xn--kln-sna.de/ +===DONE===