Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ext/standard/tests/url/url_utf8.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--TEST--
Uri: hostnames should be preserved in Unicode form
--FILE--
<?php

$parsed = parse_url('http://ουτοπία.δπθ.gr/');
var_dump($parsed['host']);
?>
--EXPECT--
string(24) "ουτοπία.δπθ.gr"
24 changes: 24 additions & 0 deletions ext/standard/url.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#if defined(__APPLE__)
#include <wchar.h>
#endif
#if defined(__APPLE__)
#include <wctype.h>
#endif

#include "php.h"

Expand Down Expand Up @@ -58,6 +64,24 @@ static void parse_url_free_uri(void *uri)

static void php_replace_controlchars(char *str, size_t len)
{
#if defined(__APPLE__)
{
ZEND_ASSERT(str != NULL);
wchar_t wbuf[len];
memset(wbuf, 0, sizeof(wbuf));
size_t wlen = mbstowcs(wbuf, str, len);

for (size_t i = 0; i < wlen; i++) {
if (iswcntrl(wbuf[i])) {
wbuf[i] = L'_';
}
}

wcstombs(str, wbuf, len);
return;
}
#endif

unsigned char *s = (unsigned char *)str;
unsigned char *e = (unsigned char *)str + len;

Expand Down