[LLVMbugs] [Bug 16023] New: regex constructor does not throw an exception for invalid escapes (unless they are in character classes)
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed May 15 19:04:59 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=16023
Bug ID: 16023
Summary: regex constructor does not throw an exception for
invalid escapes (unless they are in character classes)
Product: libc++
Version: unspecified
Hardware: Macintosh
OS: All
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: hhinnant at apple.com
Reporter: william.w.fisher+llvm at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 10520
--> http://llvm.org/bugs/attachment.cgi?id=10520&action=edit
test case
This code correctly throws a regex_error:
std::regex char_class_escape("[\\a]");
However, this code does not:
std::regex escape("\\a");
\a is an invalid escape for ECMAScript so both cases should fail to parse.
This patch fixes the problem in basic_regex::__parse_character_escape:
Index: include/regex
===================================================================
--- include/regex (revision 181970)
+++ include/regex (working copy)
@@ -4481,7 +4481,7 @@
++__first;
}
#ifndef _LIBCPP_NO_EXCEPTIONS
- else if (__str)
+ else
throw regex_error(regex_constants::error_escape);
#endif // _LIBCPP_NO_EXCEPTIONS
break;
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130516/eb8ec499/attachment.html>
More information about the llvm-bugs
mailing list