boostorg / spirit

Boost.org spirit module
http://boost.org/libs/spirit
393 stars 161 forks source link

any_char parser accepts chars outside encoding #520

Closed sehe closed 5 years ago

sehe commented 5 years ago

The following assert fails:

#include <boost/spirit/home/x3.hpp>

int main() {
    namespace x3 = boost::spirit::x3;

    char const* input = "\x80";
    assert(!x3::parse(input, input+1, x3::ascii::char_));
}

The assert should pass because char_encoding::ascii::test disallows non-7bit ASCII, so "\x80" is outside the encoding.

The corresponding Qi test case DOES pass:

#include <boost/spirit/include/qi.hpp>

int main() {
    namespace qi = boost::spirit::qi;

    char const* input = "\x80";
    assert(!qi::parse(input, input+1, qi::ascii::char_));
}

As noticed on stackoverflow https://stackoverflow.com/questions/56916592/spirit-x3-how-to-fail-parse-on-non-ascii-input

sehe commented 5 years ago

Created a merge request the most logical fix, https://github.com/boostorg/spirit/pull/521

Should not break any tests

djowel commented 5 years ago

merged.