Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
a8feeb4c
Commit
a8feeb4c
authored
May 29, 2015
by
Milo Yip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add invalid regex tests and fix a bug
parent
c0e7c830
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
+38
-0
regex.h
include/rapidjson/internal/regex.h
+2
-0
regextest.cpp
test/unittest/regextest.cpp
+36
-0
No files found.
include/rapidjson/internal/regex.h
View file @
a8feeb4c
...
...
@@ -463,6 +463,8 @@ private:
switch
(
codepoint
)
{
case
']'
:
if
(
start
==
kRegexInvalidRange
)
return
false
;
// Error: nothing inside []
if
(
step
==
2
)
{
// Add trailing '-'
SizeType
r
=
NewRange
(
'-'
);
RAPIDJSON_ASSERT
(
current
!=
kRegexInvalidRange
);
...
...
test/unittest/regextest.cpp
View file @
a8feeb4c
...
...
@@ -494,4 +494,40 @@ TEST(Regex, Escape) {
EXPECT_FALSE
(
re
.
Match
(
s
));
// Not escaping
}
TEST
(
Regex
,
Invalid
)
{
#define TEST_INVALID(s) \
{\
Regex re(s);\
EXPECT_FALSE(re.IsValid());\
}
TEST_INVALID
(
"a|"
);
TEST_INVALID
(
"()"
);
TEST_INVALID
(
")"
);
TEST_INVALID
(
"(a))"
);
TEST_INVALID
(
"(a|)"
);
TEST_INVALID
(
"(a||b)"
);
TEST_INVALID
(
"(|b)"
);
TEST_INVALID
(
"?"
);
TEST_INVALID
(
"*"
);
TEST_INVALID
(
"+"
);
TEST_INVALID
(
"{"
);
TEST_INVALID
(
"{}"
);
TEST_INVALID
(
"a{a}"
);
TEST_INVALID
(
"a{0}"
);
TEST_INVALID
(
"a{-1}"
);
TEST_INVALID
(
"a{}"
);
TEST_INVALID
(
"a{0,}"
);
TEST_INVALID
(
"a{,0}"
);
TEST_INVALID
(
"a{1,0}"
);
TEST_INVALID
(
"a{-1,0}"
);
TEST_INVALID
(
"a{-1,1}"
);
TEST_INVALID
(
"[]"
);
TEST_INVALID
(
"[^]"
);
TEST_INVALID
(
"[
\\
a]"
);
TEST_INVALID
(
"
\\
a"
);
#undef TEST_INVALID
}
#undef EURO
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment