diff --git a/features/testbot/status.feature b/features/testbot/status.feature index 8da2b155b..4c0429d13 100644 --- a/features/testbot/status.feature +++ b/features/testbot/status.feature @@ -46,22 +46,23 @@ Feature: Status messages | ab | When I route I should get - | request | status | message | - | route/v1/driving/1,1;1,2 | 200 | | - | nonsense | 400 | URL string malformed close to position 9: "nse" | - | nonsense/v1/driving/1,1;1,2 | 400 | Service nonsense not found! | - | | 400 | URL string malformed close to position 1: "/" | - | / | 400 | URL string malformed close to position 1: "//" | - | ? | 400 | URL string malformed close to position 1: "/?" | - | route/v1/driving | 400 | URL string malformed close to position 17: "ing" | - | route/v1/driving/ | 400 | URL string malformed close to position 18: "ng/" | - | route/v1/driving/1 | 400 | Query string malformed close to position 19 | - | route/v1/driving/1,1 | 400 | Number of coordinates needs to be at least two. | - | route/v1/driving/1,1,1 | 400 | Query string malformed close to position 21 | - | route/v1/driving/x | 400 | Query string malformed close to position 18 | - | route/v1/driving/x,y | 400 | Query string malformed close to position 18 | - | route/v1/driving/1,1; | 400 | Query string malformed close to position 21 | - | route/v1/driving/1,1;1 | 400 | Query string malformed close to position 23 | - | route/v1/driving/1,1;1,1,1 | 400 | Query string malformed close to position 25 | - | route/v1/driving/1,1;x | 400 | Query string malformed close to position 21 | - | route/v1/driving/1,1;x,y | 400 | Query string malformed close to position 21 | + | request | status | message | + | route/v1/driving/1,1;1,2 | 200 | | + | route/v1/driving/-74697224,5.191564 | 400 | Query string malformed close to position 18 | + | nonsense | 400 | URL string malformed close to position 9: "nse" | + | nonsense/v1/driving/1,1;1,2 | 400 | Service nonsense not found! | + | | 400 | URL string malformed close to position 1: "/" | + | / | 400 | URL string malformed close to position 1: "//" | + | ? | 400 | URL string malformed close to position 1: "/?" | + | route/v1/driving | 400 | URL string malformed close to position 17: "ing" | + | route/v1/driving/ | 400 | URL string malformed close to position 18: "ng/" | + | route/v1/driving/1 | 400 | Query string malformed close to position 19 | + | route/v1/driving/1,1 | 400 | Number of coordinates needs to be at least two. | + | route/v1/driving/1,1,1 | 400 | Query string malformed close to position 21 | + | route/v1/driving/x | 400 | Query string malformed close to position 18 | + | route/v1/driving/x,y | 400 | Query string malformed close to position 18 | + | route/v1/driving/1,1; | 400 | Query string malformed close to position 21 | + | route/v1/driving/1,1;1 | 400 | Query string malformed close to position 23 | + | route/v1/driving/1,1;1,1,1 | 400 | Query string malformed close to position 25 | + | route/v1/driving/1,1;x | 400 | Query string malformed close to position 21 | + | route/v1/driving/1,1;x,y | 400 | Query string malformed close to position 21 | diff --git a/src/server/api/parameters_parser.cpp b/src/server/api/parameters_parser.cpp index e4b201e8e..9363e4a91 100644 --- a/src/server/api/parameters_parser.cpp +++ b/src/server/api/parameters_parser.cpp @@ -55,6 +55,11 @@ boost::optional parseParameters(std::string::iterator &iter, // iterator to the failing position. Extract the position from the exception ourselves. iter = failure.first; } + catch (const boost::numeric::bad_numeric_cast &e) + { + // this can happen if we get bad numeric values in the request, just handle + // as normal parser error + } return boost::none; } diff --git a/unit_tests/server/parameters_parser.cpp b/unit_tests/server/parameters_parser.cpp index 193abb5b8..38766d07d 100644 --- a/unit_tests/server/parameters_parser.cpp +++ b/unit_tests/server/parameters_parser.cpp @@ -35,6 +35,9 @@ template std::size_t testInvalidOptions(std::string option BOOST_AUTO_TEST_CASE(invalid_route_urls) { + BOOST_CHECK_EQUAL(testInvalidOptions("a;3,4"), 0UL); + BOOST_CHECK_EQUAL(testInvalidOptions("120;3,4"), 3UL); + BOOST_CHECK_EQUAL(testInvalidOptions("90000000,2;3,4"), 0UL); BOOST_CHECK_EQUAL(testInvalidOptions("1,2;3,4?overview=false&bla=foo"), 22UL); BOOST_CHECK_EQUAL(testInvalidOptions("1,2;3,4?overview=false&bearings=foo"), 32UL);