Skip to content

Commit 22847f6

Browse files
committed
Several changes:
- JS: Don't modify the original regex to make sure we've got a complete match. Instead, we will just check if the match is exactly as long as the input text. Note that if the regex used does a non-greedy match, it will not work correctly. However, this is an unlikely scenario. e.g.: if the regex is (abc)+?, the string "abcabc" would be accepted by the server, but not by the client (the match would be "abc" (3 chars) which is shorter than "abcabc" (6 chars)). This however prevents problems with other kinds of regexes, that may be more likely. - fix error in parsing cookies
1 parent f4b7750 commit 22847f6

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/Wt/WEnvironment.C

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,8 @@ void WEnvironment::parseCookies(const std::string& cookie,
570570
boost::split(list, cookie, boost::is_any_of(";"));
571571
for (unsigned int i = 0; i < list.size(); ++i) {
572572
std::string::size_type e = list[i].find('=');
573+
if (e == std::string::npos)
574+
continue;
573575
std::string cookieName = list[i].substr(0, e);
574576
std::string cookieValue =
575577
(e != std::string::npos && list[i].size() > e + 1) ?

src/js/WRegExpValidator.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ WT_DECLARE_WT_MEMBER
1010
(1, JavaScriptConstructor, "WRegExpValidator",
1111
function(mandatory, regexp, modifiers, blankError, invalidError) {
1212

13-
var r = regexp ? new RegExp("^(" + regexp + ")$", modifiers) : null;
13+
var r = regexp ? new RegExp(regexp, modifiers) : null;
1414

1515
this.validate = function(text) {
1616
if (text.length == 0)
@@ -20,8 +20,8 @@ WT_DECLARE_WT_MEMBER
2020
return { valid: true };
2121

2222
if (r) {
23-
var result = r.test(text);
24-
if (result)
23+
var result = r.exec(text);
24+
if (result !== null && result[0].length === text.length)
2525
return { valid: true };
2626
else
2727
return { valid: false, message: invalidError };

src/js/WRegExpValidator.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)