boostorg / boostorg/regex

Exception containing invalid utf-8

Open
#262 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
119
Forks
113
PR merge metrics
No merged PRs in 30d

Description

When an invalid regex is provided, `boost::regex` throws an exception with an error message containing the regex pattern. When using a non-utf8 format the exception's `std::string` error message can end up containing invalid utf8.

The problem is on this line: https://github.com/boostorg/regex/blob/ed6ebbd5a52b566e454e0cc34494dd2912c6c66c/include/boost/regex/v5/basic_regex_parser.hpp#L236 If you use say `boost::u32regex`, then `m_base` is a `char32_t *`. Constructing a `std::string` from two `char32_t *` compiles but truncates characters, resulting in invalid utf8.

I'm not sure what the solution here is. In the mean time I've added a function to the character traits for converting a `std::basic_string` to `std::string`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.