Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
M
mongoose
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
mongoose
Commits
e4ad3010
Commit
e4ad3010
authored
Dec 30, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #416
parent
03a82ef8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
7 deletions
+8
-7
mongoose.c
mongoose.c
+5
-5
unit_test.c
test/unit_test.c
+3
-2
No files found.
mongoose.c
View file @
e4ad3010
...
...
@@ -4105,23 +4105,23 @@ static int is_dav_request(const struct connection *conn) {
static
int
parse_header
(
const
char
*
str
,
int
str_len
,
const
char
*
var_name
,
char
*
buf
,
size_t
buf_size
)
{
int
ch
=
' '
,
len
=
0
,
n
=
strlen
(
var_name
);
int
ch
=
' '
,
ch1
=
','
,
len
=
0
,
n
=
strlen
(
var_name
);
const
char
*
p
,
*
end
=
str
+
str_len
,
*
s
=
NULL
;
if
(
buf
!=
NULL
&&
buf_size
>
0
)
buf
[
0
]
=
'\0'
;
// Find where variable starts
for
(
s
=
str
;
s
!=
NULL
&&
s
+
n
<
end
;
s
++
)
{
if
((
s
==
str
||
s
[
-
1
]
==
' '
||
s
[
-
1
]
==
','
)
&&
s
[
n
]
==
'='
&&
if
((
s
==
str
||
s
[
-
1
]
==
ch
||
s
[
-
1
]
==
ch1
)
&&
s
[
n
]
==
'='
&&
!
memcmp
(
s
,
var_name
,
n
))
break
;
}
if
(
s
!=
NULL
&&
&
s
[
n
+
1
]
<
end
)
{
s
+=
n
+
1
;
if
(
*
s
==
'"'
||
*
s
==
'\''
)
ch
=
*
s
++
;
if
(
*
s
==
'"'
||
*
s
==
'\''
)
ch
=
ch1
=
*
s
++
;
p
=
s
;
while
(
p
<
end
&&
p
[
0
]
!=
ch
&&
p
[
0
]
!=
','
&&
len
<
(
int
)
buf_size
)
{
if
(
p
[
0
]
==
'\\'
&&
p
[
1
]
==
ch
)
p
++
;
while
(
p
<
end
&&
p
[
0
]
!=
ch
&&
p
[
0
]
!=
ch1
&&
len
<
(
int
)
buf_size
)
{
if
(
ch
==
ch1
&&
p
[
0
]
==
'\\'
&&
p
[
1
]
==
ch
)
p
++
;
buf
[
len
++
]
=
*
p
++
;
}
if
(
len
>=
(
int
)
buf_size
||
(
ch
!=
' '
&&
*
p
!=
ch
))
{
...
...
test/unit_test.c
View file @
e4ad3010
...
...
@@ -306,9 +306,9 @@ static const char *test_base64_encode(void) {
}
static
const
char
*
test_mg_parse_header
(
void
)
{
const
char
*
str
=
"xx=1 kl yy, ert=234 kl=123, "
const
char
*
str
=
"xx=1 kl yy, ert=234 kl=123,
uri=
\"
/?name=x,y
\"
,
"
"ii=
\"
12
\\\"
34
\"
zz='aa bb',tt=2,gf=
\"
xx d=1234"
;
char
buf
[
1
0
];
char
buf
[
2
0
];
ASSERT
(
mg_parse_header
(
str
,
"yy"
,
buf
,
sizeof
(
buf
))
==
0
);
ASSERT
(
mg_parse_header
(
str
,
"ert"
,
buf
,
sizeof
(
buf
))
==
3
);
ASSERT
(
strcmp
(
buf
,
"234"
)
==
0
);
...
...
@@ -331,6 +331,7 @@ static const char *test_mg_parse_header(void) {
ASSERT
(
strcmp
(
buf
,
"12
\"
34"
)
==
0
);
ASSERT
(
mg_parse_header
(
str
,
"tt"
,
buf
,
sizeof
(
buf
))
==
1
);
ASSERT
(
strcmp
(
buf
,
"2"
)
==
0
);
ASSERT
(
mg_parse_header
(
str
,
"uri"
,
buf
,
sizeof
(
buf
))
==
10
);
return
NULL
;
}
...
...
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