You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-dev@httpd.apache.org by Graham Barr <gb...@pobox.com> on 2002/06/20 00:21:22 UTC

my_urlword

I am having a problem with the current implementation of my_urlword.
The issue is that is splits first on &, then on ;. In our case we have
a URL which has both in (for reasons I don't really want to dig into),
which is causeing it to be parsed incorrectly.

So, is there a reson which the code works in this manner, and does not
look for both at the same time ?

If there is no particular reason, can I suggest an alternative implementation

static char *my_urlword(pool *p, const char **line)
{
    char *pos = *line;
    char ch;

    while ((ch = *pos) != NULL && ch != ';' && ch != '&')) {
	++pos;
    }

    res = ap_pstrndup(p, *line, pos - *line);

    while (ch == ';' || ch == '&') {
	++pos;
	ch = *pos;
    }

    *line = pos;

    return res;
}

Graham.


Re: my_urlword

Posted by Joe Schaefer <jo...@sunstarsys.com>.
Graham Barr <gb...@pobox.com> writes:

[...]

> static char *my_urlword(pool *p, const char **line)
> {
>     char *pos = *line;
      char *res = NULL;
>     char ch;
> 
>     while ((ch = *pos) != NULL && ch != ';' && ch != '&')) {
      while ( (ch = *pos) != '\0' && ch != ';' && ch != '&') {
> 	++pos;
>     }
> 
>     res = ap_pstrndup(p, *line, pos - *line);
> 
>     while (ch == ';' || ch == '&') {
> 	++pos;
> 	ch = *pos;
>     }
> 
>     *line = pos;
> 
>     return res;
> }

Thanks- patch applied with changes noted above.

-- 
Joe Schaefer