Opened 6 years ago
Closed 5 years ago
#12960 closed Bugs (fixed)
Line break \R in x-mode
Reported by: | Owned by: | John Maddock | |
---|---|---|---|
Milestone: | To Be Determined | Component: | regex |
Version: | Boost 1.61.0 | Severity: | Problem |
Keywords: | line-break | Cc: |
Description
Bug: get_escape_R_string()
This function injects whitespace literals in the return string.
This is a problem in x-mode since the whitespace
is ignored when it's re-parsed, which then throws an exception.
File: boost\regex\v4\regex_traits_defaults.hpp
Function: get_escape_R_string()
template <class charT> inline const charT* get_escape_R_string() { #ifdef BOOST_MSVC # pragma warning(push) # pragma warning(disable:4309 4245) #endif static const charT e1[] = { '(', '?', '>', '\x0D', '\x0A', '?', '|', '[', '\x0A', '\x0B', '\x0C', static_cast<unsigned char>('\x85'), '\\', 'x', '{', '2', '0', '2', '8', '}', '\\', 'x', '{', '2', '0', '2', '9', '}', ']', ')', '\0' }; static const charT e2[] = { '(', '?', '>', '\x0D', '\x0A', '?', '|', '[', '\x0A', '\x0B', '\x0C', static_cast<unsigned char>('\x85'), ']', ')', '\0' }; charT c = static_cast<charT>(0x2029u); bool b = (static_cast<unsigned>(c) == 0x2029u); return (b ? e1 : e2); #ifdef BOOST_MSVC # pragma warning(pop) #endif }
Can be fixed by converting the whitespace characters
to hex string literal.
static const charT e1[] = { '(', '?', '>', '\\', 'x', '0', 'D', '\\', 'x', '0', 'A', '?', '|', '[', '\\', 'x', '0', 'A', '\\', 'x', '0', 'B', '\\', 'x', '0', 'C', '\\', 'x', '8', '5', '\\', 'x', '{', '2', '0', '2', '8', '}', '\\', 'x', '{', '2', '0', '2', '9', '}', ']', ')', '\0' }; static const charT e2[] = { '(', '?', '>', '\\', 'x', '0', 'D', '\\', 'x', '0', 'A', '?', '|', '[', '\\', 'x', '0', 'A', '\\', 'x', '0', 'B', '\\', 'x', '0', 'C', '\\', 'x', '8', '5', ']', ')', '\0' };
Note:
See TracTickets
for help on using tickets.
Thanks for spotting this, fixed in https://github.com/boostorg/regex/commit/a32e0cc9d39f8c0886fe5576022c7bf0c9efc265