diff --git a/CHANGELOG.md b/CHANGELOG.md index 9576e197fe2..ea9a77349cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ - Changes from 5.25.0 - Build: - CHANGED: Replace Travis with Github Actions for CI builds [#6071](https://github.com/Project-OSRM/osrm-backend/pull/6071) + - API: + - FIXED: Allow for special characters in the profile/method as part of the HTTP URL. + # 5.25.0 - Changes from 5.24.0 - Build: @@ -119,7 +122,7 @@ ](https://github.com/Project-OSRM/osrm-backend/pull/5076/) - CHANGED: Foot profile now blacklists barriers instead of whitelisting them [#5077 ](https://github.com/Project-OSRM/osrm-backend/pull/5077/) - - CHANGED: Support maxlength and maxweight in car profile [#5101](https://github.com/Project-OSRM/osrm-backend/pull/5101] + - CHANGED: Support maxlength and maxweight in car profile [#5101](https://github.com/Project-OSRM/osrm-backend/pull/5101) - Bugfixes: - FIXED: collapsing of ExitRoundabout instructions [#5114](https://github.com/Project-OSRM/osrm-backend/issues/5114) - Misc: diff --git a/cmake/FindLua.cmake b/cmake/FindLua.cmake index 2b732ca210b..237dca8e6df 100644 --- a/cmake/FindLua.cmake +++ b/cmake/FindLua.cmake @@ -44,7 +44,7 @@ unset(_lua_append_versions) # this is a function only to have all the variables inside go away automatically function(_lua_set_version_vars) - set(LUA_VERSIONS5 5.3 5.2 5.1 5.0) + set(LUA_VERSIONS5 5.4 5.3 5.2 5.1 5.0) if (Lua_FIND_VERSION_EXACT) if (Lua_FIND_VERSION_COUNT GREATER 1) diff --git a/src/server/api/url_parser.cpp b/src/server/api/url_parser.cpp index b5da6fccedf..1a10f66c326 100644 --- a/src/server/api/url_parser.cpp +++ b/src/server/api/url_parser.cpp @@ -26,15 +26,15 @@ struct URLParser final : qi::grammar { using boost::spirit::repository::qi::iter_pos; - alpha_numeral = qi::char_("a-zA-Z0-9"); + identifier = qi::char_("a-zA-Z0-9_.~:-"); percent_encoding = qi::char_('%') > qi::uint_parser()[qi::_val = qi::_1]; - polyline_chars = qi::char_("a-zA-Z0-9_.--[]{}@?|\\~`^") | percent_encoding; - all_chars = polyline_chars | qi::char_("=,;:&()."); + polyline_chars = qi::char_("a-zA-Z0-9_[]{}@?|\\~`^") | percent_encoding; + all_chars = polyline_chars | qi::char_("=,;:&().-"); - service = +alpha_numeral; + service = +identifier; version = qi::uint_; - profile = +alpha_numeral; + profile = +identifier; query = +all_chars; // Example input: /route/v1/driving/7.416351,43.731205;7.420363,43.736189 @@ -54,7 +54,7 @@ struct URLParser final : qi::grammar qi::rule profile; qi::rule query; - qi::rule alpha_numeral; + qi::rule identifier; qi::rule all_chars; qi::rule polyline_chars; qi::rule percent_encoding; diff --git a/unit_tests/server/url_parser.cpp b/unit_tests/server/url_parser.cpp index 58f6f649659..98f05041037 100644 --- a/unit_tests/server/url_parser.cpp +++ b/unit_tests/server/url_parser.cpp @@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE(invalid_urls) BOOST_CHECK_EQUAL(testInvalidURL("/route/"), 7UL); BOOST_CHECK_EQUAL(testInvalidURL("/route/bla"), 7UL); BOOST_CHECK_EQUAL(testInvalidURL("/route/1/1,2;3;4"), 7UL); - BOOST_CHECK_EQUAL(testInvalidURL("/route/v1/pro_file/1,2;3,4"), 13UL); + BOOST_CHECK_EQUAL(testInvalidURL("/route/v1/pro[]file/1,2;3,4"), 13UL); BOOST_CHECK_EQUAL(testInvalidURL("/route/v1/profile"), 17UL); BOOST_CHECK_EQUAL(testInvalidURL("/route/v1/profile/"), 18UL); } @@ -124,6 +124,16 @@ BOOST_AUTO_TEST_CASE(valid_urls) BOOST_CHECK_EQUAL(reference_8.profile, result_8->profile); CHECK_EQUAL_RANGE(reference_8.query, result_8->query); BOOST_CHECK_EQUAL(reference_8.prefix_length, result_8->prefix_length); + + // profile with special characters + api::ParsedURL reference_9{"route", 1, "foo-bar_baz.profile", "0,1;2,3;4,5?options=value&foo=bar", 30UL}; + auto result_9 = api::parseURL("/route/v1/foo-bar_baz.profile/0,1;2,3;4,5?options=value&foo=bar"); + BOOST_CHECK(result_9); + BOOST_CHECK_EQUAL(reference_9.service, result_9->service); + BOOST_CHECK_EQUAL(reference_9.version, result_9->version); + BOOST_CHECK_EQUAL(reference_9.profile, result_9->profile); + CHECK_EQUAL_RANGE(reference_9.query, result_9->query); + BOOST_CHECK_EQUAL(reference_9.prefix_length, result_9->prefix_length); } BOOST_AUTO_TEST_SUITE_END()