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
cfbaf7f1
Commit
cfbaf7f1
authored
May 08, 2013
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose mg_url_decode to the API
parent
ce26234a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
mongoose.c
mongoose.c
+4
-9
mongoose.h
mongoose.h
+8
-0
No files found.
mongoose.c
View file @
cfbaf7f1
...
...
@@ -1635,13 +1635,8 @@ int mg_printf(struct mg_connection *conn, const char *fmt, ...) {
return
mg_vprintf
(
conn
,
fmt
,
ap
);
}
// URL-decode input buffer into destination buffer.
// 0-terminate the destination buffer. Return the length of decoded data.
// form-url-encoded data differs from URI encoding in a way that it
// uses '+' as character for space, see RFC 1866 section 8.2.1
// http://ftp.ics.uci.edu/pub/ietf/html/rfc1866.txt
static
int
url_decode
(
const
char
*
src
,
int
src_len
,
char
*
dst
,
int
dst_len
,
int
is_form_url_encoded
)
{
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')
...
...
@@ -1698,7 +1693,7 @@ int mg_get_var(const char *data, size_t data_len, const char *name,
assert
(
s
>=
p
);
// Decode variable into destination buffer
len
=
url_decode
(
p
,
(
size_t
)(
s
-
p
),
dst
,
dst_len
,
1
);
len
=
mg_
url_decode
(
p
,
(
size_t
)(
s
-
p
),
dst
,
dst_len
,
1
);
// Redirect error code from -1 to -2 (destination buffer too small).
if
(
len
==
-
1
)
{
...
...
@@ -4396,7 +4391,7 @@ static void handle_request(struct mg_connection *conn) {
*
((
char
*
)
conn
->
request_info
.
query_string
++
)
=
'\0'
;
}
uri_len
=
(
int
)
strlen
(
ri
->
uri
);
url_decode
(
ri
->
uri
,
uri_len
,
(
char
*
)
ri
->
uri
,
uri_len
+
1
,
0
);
mg_
url_decode
(
ri
->
uri
,
uri_len
,
(
char
*
)
ri
->
uri
,
uri_len
+
1
,
0
);
remove_double_dots_and_double_slashes
((
char
*
)
ri
->
uri
);
convert_uri_to_file_name
(
conn
,
path
,
sizeof
(
path
),
&
file
);
conn
->
throttle
=
set_throttle
(
conn
->
ctx
->
config
[
THROTTLE
],
...
...
mongoose.h
View file @
cfbaf7f1
...
...
@@ -333,6 +333,14 @@ const char *mg_get_builtin_mime_type(const char *file_name);
// Return Mongoose version.
const
char
*
mg_version
(
void
);
// URL-decode input buffer into destination buffer.
// 0-terminate the destination buffer.
// form-url-encoded data differs from URI encoding in a way that it
// uses '+' as character for space, see RFC 1866 section 8.2.1
// http://ftp.ics.uci.edu/pub/ietf/html/rfc1866.txt
// Return: length of the decoded data, or -1 if dst buffer is too small.
int
mg_url_decode
(
const
char
*
src
,
int
src_len
,
char
*
dst
,
int
dst_len
,
int
is_form_url_encoded
);
// MD5 hash given strings.
// Buffer 'buf' must be 33 bytes long. Varargs is a NULL terminated list of
...
...
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