Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
71dd7a96
Commit
71dd7a96
authored
Nov 23, 2013
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mg_url_decode() moved to string.c
parent
886dcb3f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
50 deletions
+50
-50
mongoose.c
build/src/mongoose.c
+0
-25
string.c
build/src/string.c
+25
-0
mongoose.c
mongoose.c
+25
-25
No files found.
build/src/mongoose.c
View file @
71dd7a96
...
...
@@ -259,31 +259,6 @@ int mg_write(struct mg_connection *conn, const void *buf, int len) {
(
int64_t
)
len
);
}
int
mg_url_decode
(
const
char
*
src
,
int
src_len
,
char
*
dst
,
int
dst_len
,
int
is_form_url_encoded
)
{
int
i
,
j
,
a
,
b
;
#define HEXTOI(x) (isdigit(x) ? x - '0' : x - 'W')
for
(
i
=
j
=
0
;
i
<
src_len
&&
j
<
dst_len
-
1
;
i
++
,
j
++
)
{
if
(
src
[
i
]
==
'%'
&&
i
<
src_len
-
2
&&
isxdigit
(
*
(
const
unsigned
char
*
)
(
src
+
i
+
1
))
&&
isxdigit
(
*
(
const
unsigned
char
*
)
(
src
+
i
+
2
)))
{
a
=
tolower
(
*
(
const
unsigned
char
*
)
(
src
+
i
+
1
));
b
=
tolower
(
*
(
const
unsigned
char
*
)
(
src
+
i
+
2
));
dst
[
j
]
=
(
char
)
((
HEXTOI
(
a
)
<<
4
)
|
HEXTOI
(
b
));
i
+=
2
;
}
else
if
(
is_form_url_encoded
&&
src
[
i
]
==
'+'
)
{
dst
[
j
]
=
' '
;
}
else
{
dst
[
j
]
=
src
[
i
];
}
}
dst
[
j
]
=
'\0'
;
// Null-terminate the destination
return
i
>=
src_len
?
j
:
-
1
;
}
int
mg_get_var
(
const
char
*
data
,
size_t
data_len
,
const
char
*
name
,
char
*
dst
,
size_t
dst_len
)
{
const
char
*
p
,
*
e
,
*
s
;
...
...
build/src/string.c
View file @
71dd7a96
...
...
@@ -286,6 +286,31 @@ void mg_url_encode(const char *src, char *dst, size_t dst_len) {
*
dst
=
'\0'
;
}
int
mg_url_decode
(
const
char
*
src
,
int
src_len
,
char
*
dst
,
int
dst_len
,
int
is_form_url_encoded
)
{
int
i
,
j
,
a
,
b
;
#define HEXTOI(x) (isdigit(x) ? x - '0' : x - 'W')
for
(
i
=
j
=
0
;
i
<
src_len
&&
j
<
dst_len
-
1
;
i
++
,
j
++
)
{
if
(
src
[
i
]
==
'%'
&&
i
<
src_len
-
2
&&
isxdigit
(
*
(
const
unsigned
char
*
)
(
src
+
i
+
1
))
&&
isxdigit
(
*
(
const
unsigned
char
*
)
(
src
+
i
+
2
)))
{
a
=
tolower
(
*
(
const
unsigned
char
*
)
(
src
+
i
+
1
));
b
=
tolower
(
*
(
const
unsigned
char
*
)
(
src
+
i
+
2
));
dst
[
j
]
=
(
char
)
((
HEXTOI
(
a
)
<<
4
)
|
HEXTOI
(
b
));
i
+=
2
;
}
else
if
(
is_form_url_encoded
&&
src
[
i
]
==
'+'
)
{
dst
[
j
]
=
' '
;
}
else
{
dst
[
j
]
=
src
[
i
];
}
}
dst
[
j
]
=
'\0'
;
// Null-terminate the destination
return
i
>=
src_len
?
j
:
-
1
;
}
// Check whether full request is buffered. Return:
// -1 if request is malformed
// 0 if request is not yet fully buffered
...
...
mongoose.c
View file @
71dd7a96
...
...
@@ -766,6 +766,31 @@ void mg_url_encode(const char *src, char *dst, size_t dst_len) {
*
dst
=
'\0'
;
}
int
mg_url_decode
(
const
char
*
src
,
int
src_len
,
char
*
dst
,
int
dst_len
,
int
is_form_url_encoded
)
{
int
i
,
j
,
a
,
b
;
#define HEXTOI(x) (isdigit(x) ? x - '0' : x - 'W')
for
(
i
=
j
=
0
;
i
<
src_len
&&
j
<
dst_len
-
1
;
i
++
,
j
++
)
{
if
(
src
[
i
]
==
'%'
&&
i
<
src_len
-
2
&&
isxdigit
(
*
(
const
unsigned
char
*
)
(
src
+
i
+
1
))
&&
isxdigit
(
*
(
const
unsigned
char
*
)
(
src
+
i
+
2
)))
{
a
=
tolower
(
*
(
const
unsigned
char
*
)
(
src
+
i
+
1
));
b
=
tolower
(
*
(
const
unsigned
char
*
)
(
src
+
i
+
2
));
dst
[
j
]
=
(
char
)
((
HEXTOI
(
a
)
<<
4
)
|
HEXTOI
(
b
));
i
+=
2
;
}
else
if
(
is_form_url_encoded
&&
src
[
i
]
==
'+'
)
{
dst
[
j
]
=
' '
;
}
else
{
dst
[
j
]
=
src
[
i
];
}
}
dst
[
j
]
=
'\0'
;
// Null-terminate the destination
return
i
>=
src_len
?
j
:
-
1
;
}
// Check whether full request is buffered. Return:
// -1 if request is malformed
// 0 if request is not yet fully buffered
...
...
@@ -2828,31 +2853,6 @@ int mg_write(struct mg_connection *conn, const void *buf, int len) {
(
int64_t
)
len
);
}
int
mg_url_decode
(
const
char
*
src
,
int
src_len
,
char
*
dst
,
int
dst_len
,
int
is_form_url_encoded
)
{
int
i
,
j
,
a
,
b
;
#define HEXTOI(x) (isdigit(x) ? x - '0' : x - 'W')
for
(
i
=
j
=
0
;
i
<
src_len
&&
j
<
dst_len
-
1
;
i
++
,
j
++
)
{
if
(
src
[
i
]
==
'%'
&&
i
<
src_len
-
2
&&
isxdigit
(
*
(
const
unsigned
char
*
)
(
src
+
i
+
1
))
&&
isxdigit
(
*
(
const
unsigned
char
*
)
(
src
+
i
+
2
)))
{
a
=
tolower
(
*
(
const
unsigned
char
*
)
(
src
+
i
+
1
));
b
=
tolower
(
*
(
const
unsigned
char
*
)
(
src
+
i
+
2
));
dst
[
j
]
=
(
char
)
((
HEXTOI
(
a
)
<<
4
)
|
HEXTOI
(
b
));
i
+=
2
;
}
else
if
(
is_form_url_encoded
&&
src
[
i
]
==
'+'
)
{
dst
[
j
]
=
' '
;
}
else
{
dst
[
j
]
=
src
[
i
];
}
}
dst
[
j
]
=
'\0'
;
// Null-terminate the destination
return
i
>=
src_len
?
j
:
-
1
;
}
int
mg_get_var
(
const
char
*
data
,
size_t
data_len
,
const
char
*
name
,
char
*
dst
,
size_t
dst_len
)
{
const
char
*
p
,
*
e
,
*
s
;
...
...
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