Make the API grammar more strict to actually error
This commit is contained in:
+15
-5
@@ -39,11 +39,21 @@ template <typename Iterator, class HandlerT> struct APIGrammar : qi::grammar<Ite
|
||||
explicit APIGrammar(HandlerT *h) : APIGrammar::base_type(api_call), handler(h)
|
||||
{
|
||||
api_call = qi::lit('/') >> string[boost::bind(&HandlerT::setService, handler, ::_1)] >>
|
||||
*(query) >> -(uturns);
|
||||
query = ('?') >> (+(zoom | output | jsonp | checksum | location | destination | source | hint | timestamp | bearing | u | cmp |
|
||||
-query;
|
||||
query = ('?') >> +(zoom | output | jsonp | checksum | uturns | location_with_options | destination_with_options | source_with_options | cmp |
|
||||
language | instruction | geometry | alt_route | old_API | num_results |
|
||||
matching_beta | gps_precision | classify | locs));
|
||||
|
||||
matching_beta | gps_precision | classify | locs);
|
||||
// all combinations of timestamp, uturn, hint and bearing without duplicates
|
||||
t_u = (u >> -timestamp) | (timestamp >> -u);
|
||||
t_h = (hint >> -timestamp) | (timestamp >> -hint);
|
||||
u_h = (u >> -hint) | (hint >> -u);
|
||||
t_u_h = (hint >> -t_u) | (u >> -t_h) | (timestamp >> -u_h);
|
||||
location_options = (bearing >> -t_u_h) | (t_u_h >> -bearing) | //
|
||||
(u >> bearing >> -t_h) | (timestamp >> bearing >> -u_h) | (hint >> bearing >> t_u) | //
|
||||
(t_h >> bearing >> -u) | (u_h >> bearing >> -timestamp) | (t_u >> bearing >> -hint);
|
||||
location_with_options = location >> -location_options;
|
||||
source_with_options = source >> -location_options;
|
||||
destination_with_options = destination >> -location_options;
|
||||
zoom = (-qi::lit('&')) >> qi::lit('z') >> '=' >>
|
||||
qi::short_[boost::bind(&HandlerT::setZoomLevel, handler, ::_1)];
|
||||
output = (-qi::lit('&')) >> qi::lit("output") >> '=' >>
|
||||
@@ -101,7 +111,7 @@ template <typename Iterator, class HandlerT> struct APIGrammar : qi::grammar<Ite
|
||||
stringforPolyline = +(qi::char_("a-zA-Z0-9_.-[]{}@?|\\%~`^"));
|
||||
}
|
||||
|
||||
qi::rule<Iterator> api_call, query;
|
||||
qi::rule<Iterator> api_call, query, location_options, location_with_options, destination_with_options, source_with_options, t_u, t_h, u_h, t_u_h;
|
||||
qi::rule<Iterator, std::string()> service, zoom, output, string, jsonp, checksum, location, destination, source,
|
||||
hint, timestamp, bearing, stringwithDot, stringwithPercent, language, geometry, cmp, alt_route, u,
|
||||
uturns, old_API, num_results, matching_beta, gps_precision, classify, locs, instruction, stringforPolyline;
|
||||
|
||||
Reference in New Issue
Block a user