From 0076a5a91630457715d6cbc01b906a43888c338b Mon Sep 17 00:00:00 2001 From: artemp Date: Wed, 1 Mar 2017 10:27:12 +0100 Subject: [PATCH] make hex parser strict (expecting two characters after \x) to avoid greedy parsing of trailing characters as in "\xF0\x9F\x8D\xB7abc" ==> ... + "\xB7" + "abc" not "\xB7abc" --- include/mapnik/expression_grammar_x3_def.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/mapnik/expression_grammar_x3_def.hpp b/include/mapnik/expression_grammar_x3_def.hpp index 0be7fb483..23735e5de 100644 --- a/include/mapnik/expression_grammar_x3_def.hpp +++ b/include/mapnik/expression_grammar_x3_def.hpp @@ -63,7 +63,7 @@ namespace mapnik { namespace grammar { using x3::no_case; using x3::alpha; using x3::alnum; - using x3::hex; + x3::uint_parser const hex2 {}; auto do_assign = [] (auto const& ctx) { @@ -302,8 +302,8 @@ namespace mapnik { namespace grammar { x3::rule > const regex_replace_expression("regex replace expression"); // strings - auto const single_quoted_string = x3::rule {} = lit('\'') >> no_skip[*(unesc_char | ("\\x" > hex) | (char_ - '\''))] > '\''; - auto const double_quoted_string = x3::rule {} = lit('"') >> no_skip[*(unesc_char | ("\\x" > hex) | (char_ - '"'))] > '"'; + auto const single_quoted_string = x3::rule {} = lit('\'') >> no_skip[*(unesc_char | ("\\x" > hex2) | (char_ - '\''))] > '\''; + auto const double_quoted_string = x3::rule {} = lit('"') >> no_skip[*(unesc_char | ("\\x" > hex2) | (char_ - '"'))] > '"'; auto const quoted_string = x3::rule {} = single_quoted_string | double_quoted_string; auto const unquoted_ustring = x3::rule {} = no_skip[alpha > *alnum] - lit("not");