File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed
Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change 1818#include <string.h>
1919#include <ctype.h>
2020#include <sys/types.h>
21+ #include <wchar.h>
2122
2223#include "php.h"
2324
@@ -46,20 +47,22 @@ PHPAPI void php_url_free(php_url *theurl)
4647 efree (theurl );
4748}
4849/* }}} */
49-
50+
5051static void php_replace_controlchars (char * str , size_t len )
5152{
52- unsigned char * s = (unsigned char * )str ;
53- unsigned char * e = (unsigned char * )str + len ;
53+ assert (str != NULL );
5454
55- ZEND_ASSERT (str != NULL );
55+ wchar_t wbuf [len ];
56+ memset (wbuf , 0 , sizeof (wbuf ));
57+ size_t wlen = mbstowcs (wbuf , str , len );
5658
57- while (s < e ) {
58- if (* s <= 0x1F || * s == 0x7F ) {
59- * s = '_' ;
60- }
61- s ++ ;
62- }
59+ for (size_t i = 0 ; i < wlen ; i ++ ) {
60+ if (iswcntrl (wbuf [i ])) {
61+ wbuf [i ] = L'_' ;
62+ }
63+ }
64+
65+ wcstombs (str , wbuf , len );
6366}
6467
6568PHPAPI php_url * php_url_parse (char const * str )
You can’t perform that action at this time.
0 commit comments