Boost logo

Boost :

From: Julien Blanc (julien.blanc_at_[hidden])
Date: 2021-10-13 05:56:15


Le mercredi 13 octobre 2021 à 11:27 +1300, Gavin Lambert via Boost a
écrit :
> On 13/10/2021 10:15, Vinnie Falco wrote:
> > Okay, I think what you're saying is that you will have this string
> > literal:
> >
> >      string_view s = "http://example.com/\xf0\x9f\x92\xa9";
> >
> > Unfortunately, this is not a valid URL and I don't think that the
> > library should accept this input. However, you could write this:
> >
> >      url u = parse_uri( "http://example.com" ).value();
> >
> >      u.set_path( "/\xf0\x9f\x92\xa9" );
>
> Why would set_path accept encoding that parse_uri does not?  That
> sounds like a red flag.

I would not say so. I see 2 different use cases :
* parse an uri : the uri must be properly encoded
* programatically build an uri: the different components shall not be
encoded.

-> u.set_path("%f0%9f%92%a9") will then produce
"http://example.com/%25f0%259f%2592%25a9".

However, that seems inconsistent with the way set_host works (the docs
says it needs to be encoded), so i tend to agree with the red flag here
(or maybe they're just documentation issues, since there is also
set_encoded_host). And then there's the issue of the '/' character in
set_path if you take unencoded strings (not sure how this should be
handled...)

Regards,

Julien


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk