includeos / acorn

Acorn Web Server Appliance, built with IncludeOS
Apache License 2.0
93 stars 13 forks source link

Cookie constructor does not handle long Max-Age setting, throws unexpected exception #42

Closed ingve closed 8 years ago

ingve commented 8 years ago

When calling the Cookie constructor I would expect to get a valid Cookie or having a CookieException thrown.

This works:

  using namespace std::string_literals;
  try {
    std::vector<std::string> options {"Max-Age"s, "-1"s};
    cookie::Cookie c {"USER_TOKEN"s, "1mbda"s, options};
    std::cout << c << std::endl;
  }
  catch (const cookie::CookieException& ce) {
    std::cout << "bad cookie!" << std::endl;
  }

This does not:

    using namespace std::string_literals;
    try {
      std::vector<std::string> options {"Max-Age"s, "9999999999"s};
      cookie::Cookie c {"USER_TOKEN"s, "1mbda"s, options};
      std::cout << c << std::endl;
    }
    catch (const cookie::CookieException& ce) {
      std::cout << "bad cookie!" << std::endl;
    }
    // => terminating with uncaught exception of type std::out_of_range: stoi: out of range