Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#3459 closed Bugs (invalid)

Xpressive - Redundant search pattern causes fatal crash

Reported by: Eric Schwarz <master.universe@…> Owned by: Eric Niebler
Milestone: Boost 1.41.0 Component: xpressive
Version: Boost 1.40.0 Severity: Showstopper
Keywords: Xpressive core dumped fatal crash Cc: master.universe@…

Description

Using Xpressive with dynamic regexes.

If a ':' appears two times in a search pattern expression the programm will crash.

One ':' must be at the very beginning the other at the end of the expression.

This may hold true for other cases, however not tested yet.

#include <string> #include <iostream> #include <boost/xpressive/xpressive.hpp>

using namespace std; using namespace boost; using namespace boost::xpressive;

int main() {

sregex rex = sregex::compile( "[:digit:]" );

return 0;

}

Change History (3)

comment:1 by Eric Niebler, 13 years ago

Resolution: invalid
Status: newclosed

"[:digit:]" is an invalid regular expression. The code is not crashing. It is throwing an exception, as it should. You probably meant: ":digit:".

comment:2 by master.universe@…, 13 years ago

Cc: master.universe@… added

Well. But why does [:digit:] throw but [:digi:t] does _not_? No. I really ment [:digit:] . For my favour to be interpreted as possbile match pattern - right?

comment:3 by Eric Niebler, 13 years ago

A pattern may contain a character set (which begins with '[' and ends with ']'). A character set may contain a nested posix character set (which begins with "[:" and ends with ":]"). Xpressive's regex parser sees the leading '[' and parses the rest as a character set containing the characters ':', 'd', 'i', 'g', 'i', and 't' (very much not what you want, but perfectly correct according to the ECMA-262 specification). Now it reads ":]" as a single token and, having found a closing posix charset bracket without an opening one, it throws an exception.

I repeat: you meant ":digit:". If you still disagree, please back up your argument with the relevant portion of ECMA-262.

Note: See TracTickets for help on using tickets.