Undefined behavior when missing fields in URI #72

Closed
dhbaird opened this Issue Oct 6, 2011 · 1 comment

Comments

Projects
None yet
2 participants
@dhbaird

dhbaird commented Oct 6, 2011

What happens if I call user_info(uri) on the following URL? It seems behavior is undefined, and there is no clear way to check if user_info exists or not.

boost::network::uri::uri uri("http://foo.com/");

An API change to something like the following is one possibility:

assert(user_info(uri) == "");
assert(has_user_info(uri) == false);

And the case where the user_info data is present:

boost::network::uri::uri uri("http://user:pass@foo.com/");
assert(user_info(uri) == "user:pass");
assert(has_user_info(uri) == true);

(similar changes would need to be made for query(), et al.)

@ghost ghost assigned glynos Nov 24, 2011

@glynos

This comment has been minimized.

Show comment
Hide comment
@glynos

glynos Dec 10, 2011

Member

This bug was introduced when I changed the implementation from strings to iterator_range. The parts that were empty were simply not being initialized. I fixed the failures by reverting all the iterator ranges to strings again in uri_parts.

I still think using iterator_range is a better strategy in the long run, but I didn't have enough experience in Boost.Spirit to apply this correctly.

All tests now pass on MSVC 10.0 and GCC 4.4.

Member

glynos commented Dec 10, 2011

This bug was introduced when I changed the implementation from strings to iterator_range. The parts that were empty were simply not being initialized. I fixed the failures by reverting all the iterator ranges to strings again in uri_parts.

I still think using iterator_range is a better strategy in the long run, but I didn't have enough experience in Boost.Spirit to apply this correctly.

All tests now pass on MSVC 10.0 and GCC 4.4.

@glynos glynos closed this Dec 10, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment