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
7083bea5
Commit
7083bea5
authored
Jan 28, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mg_parse_header(): allowing no spaces for comma-separated list
parent
3dffd760
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
mongoose.c
mongoose.c
+2
-2
unit_test.c
unit_test.c
+3
-1
No files found.
mongoose.c
View file @
7083bea5
...
@@ -3042,7 +3042,7 @@ int parse_header(const char *str, int str_len, const char *var_name, char *buf,
...
@@ -3042,7 +3042,7 @@ int parse_header(const char *str, int str_len, const char *var_name, char *buf,
// Find where variable starts
// Find where variable starts
for
(
s
=
str
;
s
!=
NULL
&&
s
+
n
<
end
;
s
++
)
{
for
(
s
=
str
;
s
!=
NULL
&&
s
+
n
<
end
;
s
++
)
{
if
((
s
==
str
||
s
[
-
1
]
==
' '
)
&&
s
[
n
]
==
'='
&&
if
((
s
==
str
||
s
[
-
1
]
==
' '
||
s
[
-
1
]
==
','
)
&&
s
[
n
]
==
'='
&&
!
memcmp
(
s
,
var_name
,
n
))
break
;
!
memcmp
(
s
,
var_name
,
n
))
break
;
}
}
...
@@ -3050,7 +3050,7 @@ int parse_header(const char *str, int str_len, const char *var_name, char *buf,
...
@@ -3050,7 +3050,7 @@ int parse_header(const char *str, int str_len, const char *var_name, char *buf,
s
+=
n
+
1
;
s
+=
n
+
1
;
if
(
*
s
==
'"'
||
*
s
==
'\''
)
ch
=
*
s
++
;
if
(
*
s
==
'"'
||
*
s
==
'\''
)
ch
=
*
s
++
;
p
=
s
;
p
=
s
;
while
(
p
<
end
&&
p
[
0
]
!=
ch
&&
len
<
(
int
)
buf_size
)
{
while
(
p
<
end
&&
p
[
0
]
!=
ch
&&
p
[
0
]
!=
','
&&
len
<
(
int
)
buf_size
)
{
if
(
p
[
0
]
==
'\\'
&&
p
[
1
]
==
ch
)
p
++
;
if
(
p
[
0
]
==
'\\'
&&
p
[
1
]
==
ch
)
p
++
;
buf
[
len
++
]
=
*
p
++
;
buf
[
len
++
]
=
*
p
++
;
}
}
...
...
unit_test.c
View file @
7083bea5
...
@@ -322,7 +322,7 @@ static const char *test_base64_encode(void) {
...
@@ -322,7 +322,7 @@ static const char *test_base64_encode(void) {
static
const
char
*
test_mg_parse_header
(
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, "
"ii=
\"
12
\\\"
34
\"
zz='aa bb',
gf=
\"
xx d=1234"
;
"ii=
\"
12
\\\"
34
\"
zz='aa bb',
tt=2,
gf=
\"
xx d=1234"
;
char
buf
[
10
];
char
buf
[
10
];
ASSERT
(
mg_parse_header
(
str
,
"yy"
,
buf
,
sizeof
(
buf
))
==
0
);
ASSERT
(
mg_parse_header
(
str
,
"yy"
,
buf
,
sizeof
(
buf
))
==
0
);
ASSERT
(
mg_parse_header
(
str
,
"ert"
,
buf
,
sizeof
(
buf
))
==
3
);
ASSERT
(
mg_parse_header
(
str
,
"ert"
,
buf
,
sizeof
(
buf
))
==
3
);
...
@@ -344,6 +344,8 @@ static const char *test_mg_parse_header(void) {
...
@@ -344,6 +344,8 @@ static const char *test_mg_parse_header(void) {
ASSERT
(
strcmp
(
buf
,
"1"
)
==
0
);
ASSERT
(
strcmp
(
buf
,
"1"
)
==
0
);
ASSERT
(
mg_parse_header
(
str
,
"ii"
,
buf
,
sizeof
(
buf
))
==
5
);
ASSERT
(
mg_parse_header
(
str
,
"ii"
,
buf
,
sizeof
(
buf
))
==
5
);
ASSERT
(
strcmp
(
buf
,
"12
\"
34"
)
==
0
);
ASSERT
(
strcmp
(
buf
,
"12
\"
34"
)
==
0
);
ASSERT
(
mg_parse_header
(
str
,
"tt"
,
buf
,
sizeof
(
buf
))
==
1
);
ASSERT
(
strcmp
(
buf
,
"2"
)
==
0
);
return
NULL
;
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