[PHP-CVS] cvs: php-src /ext/standard url.c
felipe Tue Jul 29 12:36:36 2008 UTC Modified files: /php-src/ext/standard url.c Log: - Fix mem. leak http://cvs.php.net/viewvc.cgi/php-src/ext/standard/url.c?r1=1.108r2=1.109diff_format=u Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.108 php-src/ext/standard/url.c:1.109 --- php-src/ext/standard/url.c:1.108Wed Jun 4 19:34:45 2008 +++ php-src/ext/standard/url.c Tue Jul 29 12:36:36 2008 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.108 2008/06/04 19:34:45 rrichards Exp $ */ +/* $Id: url.c,v 1.109 2008/07/29 12:36:36 felipe Exp $ */ #include stdlib.h #include string.h @@ -420,6 +420,7 @@ resource = php_url_parse_ex(str.s, str_len); if (resource == NULL) { php_error_docref1(NULL TSRMLS_CC, str.s, E_WARNING, Unable to parse URL); + efree(str.s); RETURN_FALSE; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c
felipe Tue Jul 29 12:41:58 2008 UTC Modified files: /php-src/ext/standard url.c Log: - Fix the fix http://cvs.php.net/viewvc.cgi/php-src/ext/standard/url.c?r1=1.109r2=1.110diff_format=u Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.109 php-src/ext/standard/url.c:1.110 --- php-src/ext/standard/url.c:1.109Tue Jul 29 12:36:36 2008 +++ php-src/ext/standard/url.c Tue Jul 29 12:41:58 2008 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.109 2008/07/29 12:36:36 felipe Exp $ */ +/* $Id: url.c,v 1.110 2008/07/29 12:41:58 felipe Exp $ */ #include stdlib.h #include string.h @@ -420,7 +420,9 @@ resource = php_url_parse_ex(str.s, str_len); if (resource == NULL) { php_error_docref1(NULL TSRMLS_CC, str.s, E_WARNING, Unable to parse URL); - efree(str.s); + if (type == IS_UNICODE) { + efree(str.s); + } RETURN_FALSE; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c
rrichards Wed Jun 4 19:34:45 2008 UTC Modified files: /php-src/ext/standard url.c Log: rawurlencode now conforms to rfc 3986 (~ is not encoded) [DOC] http://cvs.php.net/viewvc.cgi/php-src/ext/standard/url.c?r1=1.107r2=1.108diff_format=u Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.107 php-src/ext/standard/url.c:1.108 --- php-src/ext/standard/url.c:1.107Mon Dec 31 07:12:16 2007 +++ php-src/ext/standard/url.c Wed Jun 4 19:34:45 2008 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.107 2007/12/31 07:12:16 sebastian Exp $ */ +/* $Id: url.c,v 1.108 2008/06/04 19:34:45 rrichards Exp $ */ #include stdlib.h #include string.h @@ -647,7 +647,7 @@ if ((str[y] '0' str[y] != '-' str[y] != '.') || (str[y] 'A' str[y] '9') || (str[y] 'Z' str[y] 'a' str[y] != '_') || - (str[y] 'z')) { + (str[y] 'z' str[y] != '~')) { str[y++] = '%'; str[y++] = hexchars[(unsigned char) s[x] 4]; str[y] = hexchars[(unsigned char) s[x] 15]; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c
andrei Thu Dec 7 18:18:50 2006 UTC Modified files: /php-src/ext/standard url.c Log: Unicode support in parse_url(). http://cvs.php.net/viewvc.cgi/php-src/ext/standard/url.c?r1=1.103r2=1.104diff_format=u Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.103 php-src/ext/standard/url.c:1.104 --- php-src/ext/standard/url.c:1.103Thu Nov 30 22:26:27 2006 +++ php-src/ext/standard/url.c Thu Dec 7 18:18:49 2006 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.103 2006/11/30 22:26:27 andrei Exp $ */ +/* $Id: url.c,v 1.104 2006/12/07 18:18:49 andrei Exp $ */ #include stdlib.h #include string.h @@ -37,6 +37,60 @@ #endif /*APACHE*/ #endif /*_OSD_POSIX*/ + +/* + * These macros are similar to ZVAL_U_STRING*() but they select between + * Unicode/binary based on explicitly specified type, rather than the + * UG(unicode) global. They may be useful for other functions, but implementing + * them would probably require updating all of the corresponding add_*_assoc_*() + * macros, so let's keep them here for now and revisit the issue if someone else + * needs them in the future. + */ +#define ZVAL_UT_STRING(conv, type, z, s, flags) { \ + if (type == IS_UNICODE) { \ + UErrorCode status = U_ZERO_ERROR; \ + char *__s = (s); \ + int __s_len = strlen(__s); \ + UChar *u_str; \ + int u_len; \ + zend_string_to_unicode_ex(conv, u_str, u_len, __s, __s_len, status); \ + if ((flags) ZSTR_AUTOFREE) { \ + efree(__s); \ + } \ + ZVAL_UNICODEL(z, u_str, u_len, 0); \ + } else { \ + char *__s=(s); \ + Z_STRLEN_P(z) = strlen(__s);\ + Z_STRVAL_P(z) = (((flags) ZSTR_DUPLICATE) ? estrndup(__s, Z_STRLEN_P(z)) : __s); \ + Z_TYPE_P(z) = IS_STRING;\ + } \ + } + +#define ZVAL_UT_STRINGL(conv, type, z, s, l, flags) { \ + if (type == IS_UNICODE) { \ + UErrorCode status = U_ZERO_ERROR; \ + char *__s = (s); \ + int __s_len = (l); \ + UChar *u_str; \ + int u_len; \ + zend_string_to_unicode_ex(conv, u_str, u_len, __s, __s_len, status); \ + if ((flags) ZSTR_AUTOFREE) { \ + efree(__s); \ + } \ + ZVAL_UNICODEL(z, u_str, u_len, 0); \ + } else { \ + char *__s=(s); int __l=l; \ + Z_STRLEN_P(z) = __l;\ + Z_STRVAL_P(z) = (((flags) ZSTR_DUPLICATE) ? estrndup(__s, __l) : __s);\ + Z_TYPE_P(z) = IS_STRING;\ + }\ + } + +#define RETVAL_UT_STRING(conv, type, s, flags) ZVAL_UT_STRING(conv, type, return_value, s, flags) +#define RETVAL_UT_STRINGL(conv, type, s, l, flags) ZVAL_UT_STRINGL(conv, type, return_value, s, l, flags) +#define RETURN_UT_STRING(conv, type, t, flags) { RETVAL_UT_STRING(conv, type, t, flags); return; } +#define RETURN_UT_STRINGL(conv, type, t, l, flags) { RETVAL_UT_STRINGL(conv, type, t, l, flags); return; } + /* {{{ free_url */ PHPAPI void php_url_free(php_url *theurl) @@ -329,50 +383,69 @@ } /* }}} */ -/* {{{ proto mixed parse_url(string url, [int url_component]) +#define add_ascii_assoc_u_ascii_string(arg, key, str, type, duplicate) do { \ + zval *___tmp; \ + MAKE_STD_ZVAL(___tmp); \ + ZVAL_UT_STRING(UG(ascii_conv), type, ___tmp, str, duplicate); \ + add_ascii_assoc_zval(arg, key, ___tmp); \ +} while (0) + + +/* {{{ proto mixed parse_url(string url, [int url_component]) U Parse a URL and return its components */ PHP_FUNCTION(parse_url) { - char *str; + zstr str; int str_len; + zend_uchar type; php_url *resource; long key = -1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|l, str, str_len, key) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, t|l, str, str_len, type, key) == FAILURE) { return; } - resource = php_url_parse_ex(str, str_len); + if (type == IS_UNICODE) { + char *temp; + + if ((temp = zend_unicode_to_ascii(str.u, str_len TSRMLS_CC)) == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, could not convert URL parameter to ASCII);
[PHP-CVS] cvs: php-src /ext/standard url.c
andrei Thu Nov 30 22:26:27 2006 UTC Modified files: /php-src/ext/standard url.c Log: get_headers() will keep headers as binary strings. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/url.c?r1=1.102r2=1.103diff_format=u Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.102 php-src/ext/standard/url.c:1.103 --- php-src/ext/standard/url.c:1.102Thu Oct 26 17:59:53 2006 +++ php-src/ext/standard/url.c Thu Nov 30 22:26:27 2006 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.102 2006/10/26 17:59:53 andrei Exp $ */ +/* $Id: url.c,v 1.103 2006/11/30 22:26:27 andrei Exp $ */ #include stdlib.h #include string.h @@ -653,7 +653,7 @@ } /* }}} */ -/* {{{ proto array get_headers(string url[, int format]) +/* {{{ proto array get_headers(string url[, int format]) U fetches all the headers sent by the server in response to a HTTP request */ PHP_FUNCTION(get_headers) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c
andrei Thu Oct 26 17:59:53 2006 UTC Modified files: /php-src/ext/standard url.c Log: Oops. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/url.c?r1=1.101r2=1.102diff_format=u Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.101 php-src/ext/standard/url.c:1.102 --- php-src/ext/standard/url.c:1.101Thu Oct 26 17:33:33 2006 +++ php-src/ext/standard/url.c Thu Oct 26 17:59:53 2006 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.101 2006/10/26 17:33:33 andrei Exp $ */ +/* $Id: url.c,v 1.102 2006/10/26 17:59:53 andrei Exp $ */ #include stdlib.h #include string.h @@ -512,7 +512,7 @@ char *in_str, *out_str; int in_str_len, out_str_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, in_str, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, S, in_str, in_str_len) == FAILURE) { return; } @@ -596,7 +596,7 @@ char *in_str, *out_str; int in_str_len, out_str_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, in_str, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, S, in_str, in_str_len) == FAILURE) { return; } @@ -613,7 +613,7 @@ char *in_str, *out_str; int in_str_len, out_str_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, in_str, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, S, in_str, in_str_len) == FAILURE) { return; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c
tony2001Thu Sep 28 12:55:03 2006 UTC Modified files: /php-src/ext/standard url.c Log: fix #38981 (using FTP URLs in get_headers() causes crash) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/url.c?r1=1.97r2=1.98diff_format=u Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.97 php-src/ext/standard/url.c:1.98 --- php-src/ext/standard/url.c:1.97 Mon Sep 25 16:02:19 2006 +++ php-src/ext/standard/url.c Thu Sep 28 12:55:02 2006 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.97 2006/09/25 16:02:19 iliaa Exp $ */ +/* $Id: url.c,v 1.98 2006/09/28 12:55:02 tony2001 Exp $ */ #include stdlib.h #include string.h @@ -675,6 +675,11 @@ RETURN_FALSE; } + if (!stream-wrapperdata || Z_TYPE_P(stream-wrapperdata) != IS_ARRAY) { + php_stream_close(stream); + RETURN_FALSE; + } + array_init(return_value); /* check for curl-wrappers that provide headers via a special headers element */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c /ext/standard/tests/strings url_t.phpt
iliaa Thu Sep 28 14:52:55 2006 UTC Modified files: /php-src/ext/standard url.c /php-src/ext/standard/tests/strings url_t.phpt Log: MFB: Fixed bug #38859 (parse_url() fails if passing '@' in passwd). http://cvs.php.net/viewvc.cgi/php-src/ext/standard/url.c?r1=1.98r2=1.99diff_format=u Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.98 php-src/ext/standard/url.c:1.99 --- php-src/ext/standard/url.c:1.98 Thu Sep 28 12:55:02 2006 +++ php-src/ext/standard/url.c Thu Sep 28 14:52:55 2006 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.98 2006/09/28 12:55:02 tony2001 Exp $ */ +/* $Id: url.c,v 1.99 2006/09/28 14:52:55 iliaa Exp $ */ #include stdlib.h #include string.h @@ -211,7 +211,7 @@ } /* check for login and password */ - if ((p = memchr(s, '@', (e-s { + if ((p = zend_memrchr(s, '@', (e-s { if ((pp = memchr(s, ':', (p-s { if ((pp-s) 0) { ret-user = estrndup(s, (pp-s)); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/url_t.phpt?r1=1.13r2=1.14diff_format=u Index: php-src/ext/standard/tests/strings/url_t.phpt diff -u php-src/ext/standard/tests/strings/url_t.phpt:1.13 php-src/ext/standard/tests/strings/url_t.phpt:1.14 --- php-src/ext/standard/tests/strings/url_t.phpt:1.13 Tue Jun 20 19:49:44 2006 +++ php-src/ext/standard/tests/strings/url_t.phpt Thu Sep 28 14:52:55 2006 @@ -71,6 +71,7 @@ 'scheme:', 'foo+bar://[EMAIL PROTECTED]/bla', 'gg:9130731', +'http://user:@[EMAIL PROTECTED]/path?argument?value#etc', ); foreach ($sample_urls as $url) { @@ -525,11 +526,11 @@ [scheme]= string(4) http [host]= - string(19) [EMAIL PROTECTED] + string(11) www.php.net [port]= int(80) [user]= - string(6) secret + string(14) [EMAIL PROTECTED] [path]= string(10) /index.php [query]= @@ -685,6 +686,22 @@ [path]= string(7) 9130731 } +array(7) { + [scheme]= + string(4) http + [host]= + string(4) host + [user]= + string(4) user + [pass]= + string(5) @pass + [path]= + string(5) /path + [query]= + string(14) argument?value + [fragment]= + string(3) etc +} string(4) http string(11) www.php.net int(80) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c /ext/standard/tests/strings url_t.phpt
iliaa Sun Feb 12 16:40:34 2006 UTC Modified files: /php-src/ext/standard url.c /php-src/ext/standard/tests/strings url_t.phpt Log: MFB51: Fixed bug #36351 (parse_url() does not parse numeric paths properly). http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/url.c?r1=1.90r2=1.91diff_format=u Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.90 php-src/ext/standard/url.c:1.91 --- php-src/ext/standard/url.c:1.90 Wed Jan 18 14:05:28 2006 +++ php-src/ext/standard/url.c Sun Feb 12 16:40:34 2006 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.90 2006/01/18 14:05:28 iliaa Exp $ */ +/* $Id: url.c,v 1.91 2006/02/12 16:40:34 iliaa Exp $ */ #include stdlib.h #include string.h @@ -138,7 +138,7 @@ p++; } - if ((*p) == '\0' || *p == '/') { + if ((*p == '\0' || *p == '/') (p - e) 7) { goto parse_port; } http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/strings/url_t.phpt?r1=1.11r2=1.12diff_format=u Index: php-src/ext/standard/tests/strings/url_t.phpt diff -u php-src/ext/standard/tests/strings/url_t.phpt:1.11 php-src/ext/standard/tests/strings/url_t.phpt:1.12 --- php-src/ext/standard/tests/strings/url_t.phpt:1.11 Sun Dec 4 17:58:53 2005 +++ php-src/ext/standard/tests/strings/url_t.phpt Sun Feb 12 16:40:34 2006 @@ -70,6 +70,7 @@ 'http://foo.com#bar', 'scheme:', 'foo+bar://[EMAIL PROTECTED]/bla', +'gg:9130731', ); foreach ($sample_urls as $url) { @@ -678,6 +679,12 @@ [path]= string(4) /bla } +array(2) { + [scheme]= + string(2) gg + [path]= + string(7) 9130731 +} string(4) http string(11) www.php.net int(80) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c
iliaa Wed Jan 18 14:05:28 2006 UTC Modified files: /php-src/ext/standard url.c Log: MFB51: Make get_headers() use the default context. http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/url.c?r1=1.89r2=1.90diff_format=u Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.89 php-src/ext/standard/url.c:1.90 --- php-src/ext/standard/url.c:1.89 Sun Jan 1 13:09:56 2006 +++ php-src/ext/standard/url.c Wed Jan 18 14:05:28 2006 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.89 2006/01/01 13:09:56 sniper Exp $ */ +/* $Id: url.c,v 1.90 2006/01/18 14:05:28 iliaa Exp $ */ #include stdlib.h #include string.h @@ -25,6 +25,7 @@ #include php.h #include url.h +#include file.h #ifdef _OSD_POSIX #ifndef APACHE #error On this EBCDIC platform, PHP is only supported as an Apache module. @@ -658,7 +659,7 @@ { char *url; int url_len; - php_stream_context *context = NULL; + php_stream_context *context; php_stream *stream; zval **prev_val, **hdr = NULL; HashPosition pos; @@ -667,6 +668,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|l, url, url_len, format) == FAILURE) { return; } + context = FG(default_context) ? FG(default_context) : (FG(default_context) = php_stream_context_alloc()); if (!(stream = php_stream_open_wrapper_ex(url, r, REPORT_ERRORS | STREAM_USE_URL | STREAM_ONLY_GET_HEADERS, NULL, context))) { RETURN_FALSE; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c
iliaa Tue Aug 9 10:17:29 2005 EDT Modified files: /php-src/ext/standard url.c Log: Added option to parse_url() to retrieve a particular URL component. http://cvs.php.net/diff.php/php-src/ext/standard/url.c?r1=1.86r2=1.87ty=u Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.86 php-src/ext/standard/url.c:1.87 --- php-src/ext/standard/url.c:1.86 Wed Aug 3 10:08:14 2005 +++ php-src/ext/standard/url.c Tue Aug 9 10:17:28 2005 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.86 2005/08/03 14:08:14 sniper Exp $ */ +/* $Id: url.c,v 1.87 2005/08/09 14:17:28 iliaa Exp $ */ #include stdlib.h #include string.h @@ -327,15 +327,16 @@ } /* }}} */ -/* {{{ proto array parse_url(string url) +/* {{{ proto mixed parse_url(string url, [int url_component]) Parse a URL and return its components */ PHP_FUNCTION(parse_url) { char *str; int str_len; php_url *resource; + long key = -1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, str, str_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|l, str, str_len, key) == FAILURE) { return; } @@ -345,6 +346,39 @@ RETURN_FALSE; } + if (key -1) { + switch (key) { + case PHP_URL_SCHEME: + if (resource-scheme != NULL) RETVAL_STRING(resource-scheme, 1); + break; + case PHP_URL_HOST: + if (resource-host != NULL) RETVAL_STRING(resource-host, 1); + break; + case PHP_URL_PORT: + if (resource-port != 0) RETVAL_LONG(resource-port); + break; + case PHP_URL_USER: + if (resource-user != NULL) RETVAL_STRING(resource-user, 1); + break; + case PHP_URL_PASS: + if (resource-pass != NULL) RETVAL_STRING(resource-pass, 1); + break; + case PHP_URL_PATH: + if (resource-path != NULL) RETVAL_STRING(resource-path, 1); + break; + case PHP_URL_QUERY: + if (resource-query != NULL) RETVAL_STRING(resource-query, 1); + break; + case PHP_URL_FRAGMENT: + if (resource-fragment != NULL) RETVAL_STRING(resource-fragment, 1); + break; + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, Invalid url component identifier %ld., key); + RETVAL_FALSE; + } + goto done; + } + /* allocate an array for return */ array_init(return_value); @@ -365,8 +399,8 @@ add_assoc_string(return_value, query, resource-query, 1); if (resource-fragment != NULL) add_assoc_string(return_value, fragment, resource-fragment, 1); - -php_url_free(resource); +done: + php_url_free(resource); } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c
iliaa Wed May 25 23:56:23 2005 EDT Modified files: /php-src/ext/standard url.c Log: Added scheme validation for parse_url(). http://cvs.php.net/diff.php/php-src/ext/standard/url.c?r1=1.84r2=1.85ty=u Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.84 php-src/ext/standard/url.c:1.85 --- php-src/ext/standard/url.c:1.84 Mon Apr 25 19:47:37 2005 +++ php-src/ext/standard/url.c Wed May 25 23:56:21 2005 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.84 2005/04/25 23:47:37 iliaa Exp $ */ +/* $Id: url.c,v 1.85 2005/05/26 03:56:21 iliaa Exp $ */ #include stdlib.h #include string.h @@ -104,6 +104,19 @@ /* parse scheme */ if ((e = memchr(s, ':', length)) (e - s)) { + /* validate scheme */ + p = s; + while (p e) { + if (!isalnum(*p)) { + if (e + 1 ue) { + goto parse_port; + } else { + goto just_path; + } + } + p++; + } + if (*(e + 1) == '\0') { /* only scheme is available */ ret-scheme = estrndup(s, (e - s)); php_replace_controlchars_ex(ret-scheme, (e - s)); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c /ext/standard/tests/strings url_t.phpt
iliaa Mon Apr 25 19:47:38 2005 EDT Modified files: /php-src/ext/standard/tests/strings url_t.phpt /php-src/ext/standard url.c Log: Fixed bug #32813 (parse_url() does not handle scheme-only urls properly). http://cvs.php.net/diff.php/php-src/ext/standard/tests/strings/url_t.phpt?r1=1.8r2=1.9ty=u Index: php-src/ext/standard/tests/strings/url_t.phpt diff -u php-src/ext/standard/tests/strings/url_t.phpt:1.8 php-src/ext/standard/tests/strings/url_t.phpt:1.9 --- php-src/ext/standard/tests/strings/url_t.phpt:1.8 Thu Jan 27 11:37:34 2005 +++ php-src/ext/standard/tests/strings/url_t.phpt Mon Apr 25 19:47:37 2005 @@ -67,7 +67,8 @@ 'file://path/to/file', 'file:/path/to/file', 'http://1.2.3.4:/abc.asp?a=1b=2', -'http://foo.com#bar' +'http://foo.com#bar', +'scheme:' ); foreach ($sample_urls as $url) { @@ -657,3 +658,7 @@ [fragment]= string(3) bar } +array(1) { + [scheme]= + string(6) scheme +} http://cvs.php.net/diff.php/php-src/ext/standard/url.c?r1=1.83r2=1.84ty=u Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.83 php-src/ext/standard/url.c:1.84 --- php-src/ext/standard/url.c:1.83 Thu Jan 27 11:37:32 2005 +++ php-src/ext/standard/url.c Mon Apr 25 19:47:37 2005 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.83 2005/01/27 16:37:32 iliaa Exp $ */ +/* $Id: url.c,v 1.84 2005/04/25 23:47:37 iliaa Exp $ */ #include stdlib.h #include string.h @@ -104,6 +104,12 @@ /* parse scheme */ if ((e = memchr(s, ':', length)) (e - s)) { + if (*(e + 1) == '\0') { /* only scheme is available */ + ret-scheme = estrndup(s, (e - s)); + php_replace_controlchars_ex(ret-scheme, (e - s)); + goto end; + } + /* * certain schemas like mailto: and zlib: may not have any / after them * this check ensures we support those. @@ -303,7 +309,7 @@ ret-path = estrndup(s, (ue-s)); php_replace_controlchars_ex(ret-path, (ue - s)); } - +end: return ret; } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c /ext/standard/tests/strings url_t.phpt
iliaa Thu Jan 27 11:37:34 2005 EDT Modified files: /php-src/ext/standard url.c /php-src/ext/standard/tests/strings url_t.phpt Log: Fixed bug #31705 (parse_url() does not recognize http://foo.com#bar) http://cvs.php.net/diff.php/php-src/ext/standard/url.c?r1=1.82r2=1.83ty=u Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.82 php-src/ext/standard/url.c:1.83 --- php-src/ext/standard/url.c:1.82 Mon Sep 20 01:13:35 2004 +++ php-src/ext/standard/url.c Thu Jan 27 11:37:32 2005 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.82 2004/09/20 05:13:35 iliaa Exp $ */ +/* $Id: url.c,v 1.83 2005/01/27 16:37:32 iliaa Exp $ */ #include stdlib.h #include string.h @@ -182,6 +182,8 @@ if (!(p = memchr(s, '/', (ue - s { if ((p = memchr(s, '?', (ue - s { e = p; + } else if ((p = memchr(s, '#', (ue - s { + e = p; } } else { e = p; http://cvs.php.net/diff.php/php-src/ext/standard/tests/strings/url_t.phpt?r1=1.7r2=1.8ty=u Index: php-src/ext/standard/tests/strings/url_t.phpt diff -u php-src/ext/standard/tests/strings/url_t.phpt:1.7 php-src/ext/standard/tests/strings/url_t.phpt:1.8 --- php-src/ext/standard/tests/strings/url_t.phpt:1.7 Wed May 19 04:45:23 2004 +++ php-src/ext/standard/tests/strings/url_t.phpt Thu Jan 27 11:37:34 2005 @@ -66,7 +66,8 @@ 'file:///path/to/file', 'file://path/to/file', 'file:/path/to/file', -'http://1.2.3.4:/abc.asp?a=1b=2' +'http://1.2.3.4:/abc.asp?a=1b=2', +'http://foo.com#bar' ); foreach ($sample_urls as $url) { @@ -648,3 +649,11 @@ [query]= string(7) a=1b=2 } +array(3) { + [scheme]= + string(4) http + [host]= + string(7) foo.com + [fragment]= + string(3) bar +} -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c url.h
iliaa Mon Sep 20 01:13:36 2004 EDT Modified files: /php-src/ext/standard url.c url.h Log: Fixed bug #29913 (parse_url() is now binary safe). http://cvs.php.net/diff.php/php-src/ext/standard/url.c?r1=1.81r2=1.82ty=u Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.81 php-src/ext/standard/url.c:1.82 --- php-src/ext/standard/url.c:1.81 Thu Jun 17 20:44:37 2004 +++ php-src/ext/standard/url.c Mon Sep 20 01:13:35 2004 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.81 2004/06/18 00:44:37 pollita Exp $ */ +/* $Id: url.c,v 1.82 2004/09/20 05:13:35 iliaa Exp $ */ #include stdlib.h #include string.h @@ -60,15 +60,16 @@ /* {{{ php_replace_controlchars */ -PHPAPI char *php_replace_controlchars(char *str) +PHPAPI char *php_replace_controlchars_ex(char *str, int len) { unsigned char *s = (unsigned char *)str; + unsigned char *e = (unsigned char *)str + len; if (!str) { return (NULL); } - while (*s) { + while (s e) { if (iscntrl(*s)) { *s='_'; @@ -79,13 +80,21 @@ return (str); } /* }}} */ - + +PHPAPI char *php_replace_controlchars(char *str) +{ + return php_replace_controlchars_ex(str, strlen(str)); +} + +PHPAPI php_url *php_url_parse(char const *str) +{ + return php_url_parse_ex(str, strlen(str)); +} /* {{{ php_url_parse */ -PHPAPI php_url *php_url_parse(char const *str) +PHPAPI php_url *php_url_parse_ex(char const *str, int length) { - int length = strlen(str); char port_buf[6]; php_url *ret = ecalloc(1, sizeof(php_url)); char const *s, *e, *p, *pp, *ue; @@ -94,7 +103,7 @@ ue = s + length; /* parse scheme */ - if ((e = strchr(s, ':')) (e-s)) { + if ((e = memchr(s, ':', length)) (e - s)) { /* * certain schemas like mailto: and zlib: may not have any / after them * this check ensures we support those. @@ -113,14 +122,14 @@ } ret-scheme = estrndup(s, (e-s)); - php_replace_controlchars(ret-scheme); + php_replace_controlchars_ex(ret-scheme, (e - s)); length -= ++e - s; s = e; goto just_path; } else { ret-scheme = estrndup(s, (e-s)); - php_replace_controlchars(ret-scheme); + php_replace_controlchars_ex(ret-scheme, (e - s)); if (*(e+2) == '/') { s = e + 3; @@ -136,8 +145,8 @@ } } } else { - s = e + 1; if (!strncasecmp(file, ret-scheme, sizeof(file))) { + s = e + 1; goto nohost; } else { length -= ++e - s; @@ -170,8 +179,8 @@ e = ue; - if (!(p = strchr(s, '/'))) { - if ((p = strchr(s, '?'))) { + if (!(p = memchr(s, '/', (ue - s { + if ((p = memchr(s, '?', (ue - s { e = p; } } else { @@ -183,17 +192,17 @@ if ((pp = memchr(s, ':', (p-s { if ((pp-s) 0) { ret-user = estrndup(s, (pp-s)); - php_replace_controlchars(ret-user); + php_replace_controlchars_ex(ret-user, (pp - s)); } pp++; if (p-pp 0) { ret-pass = estrndup(pp, (p-pp)); - php_replace_controlchars(ret-pass); + php_replace_controlchars_ex(ret-pass, (p-pp)); } } else { ret-user = estrndup(s, (p-s)); - php_replace_controlchars(ret-user); + php_replace_controlchars_ex(ret-user, (p-s)); } s = p + 1; @@ -241,7 +250,7 @@ } ret-host = estrndup(s, (p-s)); - php_replace_controlchars(ret-host); + php_replace_controlchars_ex(ret-host, (p - s)); if (e == ue) { return ret; @@ -251,7 +260,7 @@ nohost: - if ((p = strchr(s,
[PHP-CVS] cvs: php-src /ext/standard url.c
sesser Fri May 28 07:33:24 2004 EDT Modified files: /php-src/ext/standard url.c Log: Fixed off-by-one in php_parse_url. http://cvs.php.net/diff.php/php-src/ext/standard/url.c?r1=1.79r2=1.80ty=u Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.79 php-src/ext/standard/url.c:1.80 --- php-src/ext/standard/url.c:1.79 Tue Apr 27 15:28:11 2004 +++ php-src/ext/standard/url.c Fri May 28 07:33:23 2004 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.79 2004/04/27 19:28:11 pollita Exp $ */ +/* $Id: url.c,v 1.80 2004/05/28 11:33:23 sesser Exp $ */ #include stdlib.h #include string.h @@ -86,7 +86,7 @@ PHPAPI php_url *php_url_parse(char const *str) { int length = strlen(str); - char port_buf[5]; + char port_buf[6]; php_url *ret = ecalloc(1, sizeof(php_url)); char const *s, *e, *p, *pp, *ue; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c
pollita Tue Apr 27 15:13:14 2004 EDT Modified files: /php-src/ext/standard url.c Log: BugFix 28187 parse_url does not handle scheme://[0123:4567::89]:12345/etc style IPv6 embedded address URLs http://cvs.php.net/diff.php/php-src/ext/standard/url.c?r1=1.77r2=1.78ty=u Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.77 php-src/ext/standard/url.c:1.78 --- php-src/ext/standard/url.c:1.77 Sun Jan 25 10:08:31 2004 +++ php-src/ext/standard/url.c Tue Apr 27 15:13:13 2004 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.77 2004/01/25 15:08:31 abies Exp $ */ +/* $Id: url.c,v 1.78 2004/04/27 19:13:13 pollita Exp $ */ #include stdlib.h #include string.h @@ -198,13 +198,20 @@ s = p + 1; } - + /* check for port */ - /* memrchr is a GNU specific extension - Emulate for wide compatability */ - for(p = e; *p != ':' p = s; p--); + if (*s == '[' *(e-1) == ']') { + /* Short circuit portscan, + we're dealing with an + IPv6 embedded address */ + p = s; + } else { + /* memrchr is a GNU specific extension + Emulate for wide compatability */ + for(p = e; *p != ':' p = s; p--); + } - if (*p == ':') { + if (p = s *p == ':') { if (!ret-port) { p++; if (e-p 5) { /* port cannot be longer then 5 characters */ @@ -224,6 +231,11 @@ p = e; } + if (*s == '[' *(p-1) == ']') { + s++; + p--; + } + /* check if we have a valid host, if we don't reject the string as url */ if ((p-s) 1) { STR_FREE(ret-scheme); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c
pollita Tue Apr 27 15:28:11 2004 EDT Modified files: /php-src/ext/standard url.c Log: Don't strip off those []s, it'll only create problems in wrappers and elsewhere. http://cvs.php.net/diff.php/php-src/ext/standard/url.c?r1=1.78r2=1.79ty=u Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.78 php-src/ext/standard/url.c:1.79 --- php-src/ext/standard/url.c:1.78 Tue Apr 27 15:13:13 2004 +++ php-src/ext/standard/url.c Tue Apr 27 15:28:11 2004 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.78 2004/04/27 19:13:13 pollita Exp $ */ +/* $Id: url.c,v 1.79 2004/04/27 19:28:11 pollita Exp $ */ #include stdlib.h #include string.h @@ -231,11 +231,6 @@ p = e; } - if (*s == '[' *(p-1) == ']') { - s++; - p--; - } - /* check if we have a valid host, if we don't reject the string as url */ if ((p-s) 1) { STR_FREE(ret-scheme); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c
abies Sun Jan 25 10:08:33 2004 EDT Modified files: /php-src/ext/standard url.c Log: CS http://cvs.php.net/diff.php/php-src/ext/standard/url.c?r1=1.76r2=1.77ty=u Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.76 php-src/ext/standard/url.c:1.77 --- php-src/ext/standard/url.c:1.76 Sat Jan 24 19:30:49 2004 +++ php-src/ext/standard/url.c Sun Jan 25 10:08:31 2004 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.76 2004/01/25 00:30:49 abies Exp $ */ +/* $Id: url.c,v 1.77 2004/01/25 15:08:31 abies Exp $ */ #include stdlib.h #include string.h @@ -462,8 +462,8 @@ if (*data == '+') { *dest = ' '; } - else if (*data == '%' len = 2 isxdigit((int) *(data + 1)) isxdigit((int) *(data + 2))) - { + else if (*data == '%' len = 2 isxdigit((int) *(data + 1)) + isxdigit((int) *(data + 2))) { #ifndef CHARSET_EBCDIC *dest = (char) php_htoi(data + 1); #else @@ -560,8 +560,8 @@ char *data = str; while (len--) { - if (*data == '%' len = 2 isxdigit((int) *(data + 1)) isxdigit((int) *(data + 2))) - { + if (*data == '%' len = 2 isxdigit((int) *(data + 1)) +isxdigit((int) *(data + 2))) { #ifndef CHARSET_EBCDIC *dest = (char) php_htoi(data + 1); #else -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c
moriyoshi Wed Dec 3 15:58:13 2003 EDT Modified files: /php-src/ext/standard url.c Log: Possible fix for bug #26391 (parse_url() destroys strings that contain a character in range of \x80-\xff)) Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.70 php-src/ext/standard/url.c:1.71 --- php-src/ext/standard/url.c:1.70 Sun Oct 19 16:00:51 2003 +++ php-src/ext/standard/url.c Wed Dec 3 15:58:12 2003 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.70 2003/10/19 20:00:51 shane Exp $ */ +/* $Id: url.c,v 1.71 2003/12/03 20:58:12 moriyoshi Exp $ */ #include stdlib.h #include string.h @@ -104,7 +104,7 @@ * correctly parse things like a.com:80 */ p = e + 1; - while (isdigit(*p)) { + while (isdigit((int)*(unsigned char *)p)) { p++; } @@ -151,7 +151,7 @@ p = e + 1; pp = p; - while (pp-p 6 isdigit(*pp)) { + while (pp-p 6 isdigit((int)*(unsigned char *)pp)) { pp++; } @@ -336,12 +336,12 @@ int value; int c; - c = s[0]; + c = ((unsigned char *)s)[0]; if (isupper(c)) c = tolower(c); value = (c = '0' c = '9' ? c - '0' : c - 'a' + 10) * 16; - c = s[1]; + c = ((unsigned char *)s)[1]; if (isupper(c)) c = tolower(c); value += c = '0' c = '9' ? c - '0' : c - 'a' + 10; @@ -457,7 +457,7 @@ while (len--) { if (*data == '+') *dest = ' '; - else if (*data == '%' len = 2 isxdigit((int) *(data + 1)) isxdigit((int) *(data + 2))) { + else if (*data == '%' len = 2 isxdigit((int) *(unsigned char *)(data + 1)) isxdigit((int) *(unsigned char *)(data + 2))) { #ifndef CHARSET_EBCDIC *dest = (char) php_htoi(data + 1); #else @@ -605,7 +605,7 @@ c = *p; *p = '\0'; s = p + 1; - while (isspace(*s)) { + while (isspace((int)*(unsigned char *)s)) { s++; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard url.c
Given that digits can only be in the \x48-\x57 range is (int)*(unsigned char *) cast really necessary? Ilia -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard url.c
On 2003/12/04, at 6:12, Ilia Alshanetsky wrote: Given that digits can only be in the \x48-\x57 range is (int)*(unsigned char *) cast really necessary? Nope, it's just for the sake of safety :-) Actually I didn't realize it. Moriyoshi -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard url.c
Shouldn't we nuke it then? It's ugly enough with the unsigned char cast :) Andi At 04:12 PM 12/3/2003 -0500, Ilia Alshanetsky wrote: Given that digits can only be in the \x48-\x57 range is (int)*(unsigned char *) cast really necessary? Ilia -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c
iliaa Wed Dec 3 17:51:52 2003 EDT Modified files: /php-src/ext/standard url.c Log: Remove unnecessary casts. Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.71 php-src/ext/standard/url.c:1.72 --- php-src/ext/standard/url.c:1.71 Wed Dec 3 15:58:12 2003 +++ php-src/ext/standard/url.c Wed Dec 3 17:51:51 2003 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.71 2003/12/03 20:58:12 moriyoshi Exp $ */ +/* $Id: url.c,v 1.72 2003/12/03 22:51:51 iliaa Exp $ */ #include stdlib.h #include string.h @@ -104,7 +104,7 @@ * correctly parse things like a.com:80 */ p = e + 1; - while (isdigit((int)*(unsigned char *)p)) { + while (isdigit(p)) { p++; } @@ -151,7 +151,7 @@ p = e + 1; pp = p; - while (pp-p 6 isdigit((int)*(unsigned char *)pp)) { + while (pp-p 6 isdigit(pp)) { pp++; } @@ -457,7 +457,7 @@ while (len--) { if (*data == '+') *dest = ' '; - else if (*data == '%' len = 2 isxdigit((int) *(unsigned char *)(data + 1)) isxdigit((int) *(unsigned char *)(data + 2))) { + else if (*data == '%' len = 2 isxdigit((int) *(data + 1)) isxdigit((int) *(data + 2))) { #ifndef CHARSET_EBCDIC *dest = (char) php_htoi(data + 1); #else -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard url.c
Any reason to remove them? Passing a char-typed value to is*() or to*() is basically wrong. Moriyoshi On 2003/12/04, at 7:51, Ilia Alshanetsky wrote: iliaa Wed Dec 3 17:51:52 2003 EDT Modified files: /php-src/ext/standard url.c Log: Remove unnecessary casts. Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.71 php-src/ext/standard/url.c:1.72 --- php-src/ext/standard/url.c:1.71 Wed Dec 3 15:58:12 2003 +++ php-src/ext/standard/url.c Wed Dec 3 17:51:51 2003 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +-- + */ -/* $Id: url.c,v 1.71 2003/12/03 20:58:12 moriyoshi Exp $ */ +/* $Id: url.c,v 1.72 2003/12/03 22:51:51 iliaa Exp $ */ #include stdlib.h #include string.h @@ -104,7 +104,7 @@ * correctly parse things like a.com:80 */ p = e + 1; - while (isdigit((int)*(unsigned char *)p)) { + while (isdigit(p)) { p++; } @@ -151,7 +151,7 @@ p = e + 1; pp = p; - while (pp-p 6 isdigit((int)*(unsigned char *)pp)) { + while (pp-p 6 isdigit(pp)) { pp++; } @@ -457,7 +457,7 @@ while (len--) { if (*data == '+') *dest = ' '; - else if (*data == '%' len = 2 isxdigit((int) *(unsigned char *)(data + 1)) isxdigit((int) *(unsigned char *)(data + 2))) { + else if (*data == '%' len = 2 isxdigit((int) *(data + 1)) isxdigit((int) *(data + 2))) { #ifndef CHARSET_EBCDIC *dest = (char) php_htoi(data + 1); #else -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard url.c
On December 3, 2003 06:21 pm, Moriyoshi Koizumi wrote: Any reason to remove them? Passing a char-typed value to is*() or to*() is basically wrong. Compiler does not have a problem with that and we've already established it won't change anything since 'digits' are always lower then then 128-255 range the cast protects. Ilia -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard url.c
On 2003/12/04, at 8:35, Ilia Alshanetsky wrote: On December 3, 2003 06:21 pm, Moriyoshi Koizumi wrote: Any reason to remove them? Passing a char-typed value to is*() or to*() is basically wrong. Compiler does not have a problem with that and we've already established it won't change anything since 'digits' are always lower then then 128-255 range the cast protects. Although it's not a compiler issue and the casts look ugly, I want to ask those who'll use functions like them to use unsigned char variables in the first place. I've ever spotted numerous mistakes all over the code. That's why I hope they will leave there as my warnings. Moriyoshi p.s. (int)((char)-1) yields -1, rather than 255 of cource. -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c
iliaa Wed Dec 3 19:14:40 2003 EDT Modified files: /php-src/ext/standard url.c Log: Fixed typo (thanks Frank) Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.72 php-src/ext/standard/url.c:1.73 --- php-src/ext/standard/url.c:1.72 Wed Dec 3 17:51:51 2003 +++ php-src/ext/standard/url.c Wed Dec 3 19:14:39 2003 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.72 2003/12/03 22:51:51 iliaa Exp $ */ +/* $Id: url.c,v 1.73 2003/12/04 00:14:39 iliaa Exp $ */ #include stdlib.h #include string.h @@ -104,7 +104,7 @@ * correctly parse things like a.com:80 */ p = e + 1; - while (isdigit(p)) { + while (isdigit(*p)) { p++; } @@ -151,7 +151,7 @@ p = e + 1; pp = p; - while (pp-p 6 isdigit(pp)) { + while (pp-p 6 isdigit(*pp)) { pp++; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c
shane Sun Oct 19 16:00:53 2003 EDT Modified files: /php-src/ext/standard url.c Log: make parse_url work correctly for file uri's on windows, such as file:///c:/somepath/somefile.txt Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.69 php-src/ext/standard/url.c:1.70 --- php-src/ext/standard/url.c:1.69 Mon Oct 13 00:27:23 2003 +++ php-src/ext/standard/url.c Sun Oct 19 16:00:51 2003 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.69 2003/10/13 04:27:23 iliaa Exp $ */ +/* $Id: url.c,v 1.70 2003/10/19 20:00:51 shane Exp $ */ #include stdlib.h #include string.h @@ -126,6 +126,12 @@ s = e + 3; if (!strncasecmp(file, ret-scheme, sizeof(file))) { if (*(e + 3) == '/') { + /* support windows drive letters as in: + file:///c:/somedir/file.txt + */ + if (*(e + 5) == ':') { + s = e + 4; + } goto nohost; } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c /ext/standard/tests/strings url_t.phpt
iliaa Mon Oct 13 00:27:24 2003 EDT Modified files: /php-src/ext/standard/tests/strings url_t.phpt /php-src/ext/standard url.c Log: Fixed bug #25800 (parse_url() could not parse urls with empty port). Index: php-src/ext/standard/tests/strings/url_t.phpt diff -u php-src/ext/standard/tests/strings/url_t.phpt:1.5 php-src/ext/standard/tests/strings/url_t.phpt:1.6 --- php-src/ext/standard/tests/strings/url_t.phpt:1.5 Mon Dec 30 11:42:49 2002 +++ php-src/ext/standard/tests/strings/url_t.phpt Mon Oct 13 00:27:23 2003 @@ -64,7 +64,11 @@ 'mailto:[EMAIL PROTECTED]', '/foo.php?a=bc=d', 'foo.php?a=bc=d', -'http://user:[EMAIL PROTECTED]:8080?bar=1boom=0' +'http://user:[EMAIL PROTECTED]:8080?bar=1boom=0', +'file:///path/to/file', +'file://path/to/file', +'file:/path/to/file', +'http://1.2.3.4:/abc.asp?a=1b=2' ); foreach ($sample_urls as $url) { @@ -615,4 +619,34 @@ string(6) passwd [query]= string(12) bar=1boom=0 +} +array(2) { + [scheme]= + string(4) file + [path]= + string(13) /path/to/file +} +array(3) { + [scheme]= + string(4) file + [host]= + string(4) path + [path]= + string(8) /to/file +} +array(2) { + [scheme]= + string(4) file + [path]= + string(13) /path/to/file +} +array(4) { + [scheme]= + string(4) http + [host]= + string(7) 1.2.3.4 + [path]= + string(8) /abc.asp + [query]= + string(7) a=1b=2 } Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.68 php-src/ext/standard/url.c:1.69 --- php-src/ext/standard/url.c:1.68 Mon Aug 11 19:16:53 2003 +++ php-src/ext/standard/url.c Mon Oct 13 00:27:23 2003 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.68 2003/08/11 23:16:53 iliaa Exp $ */ +/* $Id: url.c,v 1.69 2003/10/13 04:27:23 iliaa Exp $ */ #include stdlib.h #include string.h @@ -197,17 +197,17 @@ if ((p = memchr(s, ':', (e-s { if (!ret-port) { p++; - if ( e-p 5 || e-p 1 ) { /* port cannot be longer then 5 characters */ + if (e-p 5) { /* port cannot be longer then 5 characters */ STR_FREE(ret-scheme); STR_FREE(ret-user); STR_FREE(ret-pass); efree(ret); return NULL; + } else if (e - p 0) { + memcpy(port_buf, p, (e-p)); + port_buf[e-p] = '\0'; + ret-port = atoi(port_buf); } - - memcpy(port_buf, p, (e-p)); - port_buf[e-p] = '\0'; - ret-port = atoi(port_buf); p--; } } else { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard url.c
iliaa Mon Jul 21 09:36:23 2003 EDT Modified files: /php-src/ext/standard url.c Log: Fixed bug #24560 (parse_url() incorrectly handling certain file:// based schemas). Index: php-src/ext/standard/url.c diff -u php-src/ext/standard/url.c:1.66 php-src/ext/standard/url.c:1.67 --- php-src/ext/standard/url.c:1.66 Tue Jun 10 16:03:38 2003 +++ php-src/ext/standard/url.c Mon Jul 21 09:36:23 2003 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: url.c,v 1.66 2003/06/10 20:03:38 imajes Exp $ */ +/* $Id: url.c,v 1.67 2003/07/21 13:36:23 iliaa Exp $ */ #include stdlib.h #include string.h @@ -125,7 +125,9 @@ if (*(e+2) == '/') { s = e + 3; if (!strncasecmp(file, ret-scheme, sizeof(file))) { - goto nohost; + if (*(e + 3) == '/') { + goto nohost; + } } } else { s = e + 1; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php