> While waiting for opinions on Bug#20460 I went ahead and addressed #20308.
> 
> User complains that parse_url returns the full email address in 'path'
> element.  Makes reference to documents which claim it should return 'user'
> and 'host' element.
> 
> To address this request and maintain backward compatability I wrote a
> patch to split the 'path' element in to 'host' and 'user' elements then
> return all three.
> 
> Ex:
> *current behavior*
> print_r(parse_url("mailto:[EMAIL PROTECTED]";));
> Array (
>   [scheme] => mailto
>   [path] => [EMAIL PROTECTED]
> }
> 
> *new behavior*
> print_r(parse_url("mailto:[EMAIL PROTECTED]";));
> Array (
>   [scheme] => mailto
>   [path] => [EMAIL PROTECTED]
>   [user] => pollita
>   [host] => php.net
> }
> 
> If there are no objections I'll commit this change.
> 
> 
I like the idea, just 2 little things with the patch...


> 
> Index: url.c
> ===================================================================
> RCS file: /repository/php4/ext/standard/url.c,v
> retrieving revision 1.59
> diff -u -r1.59 url.c
> --- url.c     14 Nov 2002 13:40:14 -0000      1.59
> +++ url.c     27 Nov 2002 20:44:25 -0000
> @@ -267,6 +267,26 @@
>               php_replace_controlchars(ret->path);
>       }
> 
> +     if (strcmp(ret->scheme,"mailto") == 0) {
> +             s = estrndup(ret->path, strlen(ret->path));
> +             ue = s + strlen(ret->path);

why not cache this strlen() and not double calculate it.


> +             p = s + 1;
> +             /* a mailto starting with @ would be malformed, but let's keep it 
>clean */
> +             if (s[0] == '@') {
> +                     s[0] = '\0';
> +             }
> +             /* scan for @ to separate user from host */
> +             while (p < ue && p[-1] != '\0') {
> +                     if (p[0] == '@') {
> +                             p[0] = '\0';
> +                     }
> +                     p++;
> +             }

why not use strchr() or memchr() for this code?

-Sterling

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to