Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boost::url::parse_query result includes data outside the string_view passed in #757

Closed
adamhpeterson opened this issue Jun 20, 2023 · 0 comments · Fixed by #764
Closed
Assignees

Comments

@adamhpeterson
Copy link

url::parse_query() seems to parse query values beyond the data passed into the function's string_view argument. I see this using Boost 1.82.

Example reproduction:

#include <boost/url/parse.hpp>
#include <boost/url/parse_query.hpp>
#include <iostream>
#include <string>
#include <string_view>

int main() {
  auto data = std::string("abc=def&ghi=jkl&mno=pqr");
  auto view = std::string_view( data.data(), data.size() - 2 );
  auto fp = boost::urls::parse_query( view );
  for ( auto &&p : fp.value() ) {
    std::cout << "(" << p.key << ")(" << p.value << ")\n";
  }
}

// Expected output:
//  (abc)(def)
//  (ghi)(jkl)
//  (mno)(p)
// Actual output:
//  (abc)(def)
//  (ghi)(jkl)
//  (mno)(pqr)

Notice that although the string_view was shortened by 2 characters from the full string before it was passed into parse_query(), the two characters are still included in the result of the parse.

@mclow mclow transferred this issue from boostorg/boost Jun 20, 2023
@alandefreitas alandefreitas self-assigned this Jul 3, 2023
alandefreitas added a commit to alandefreitas/url that referenced this issue Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants