From c948a509fb1abfc23092e1356bf22ccfe467d791 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Thu, 3 Dec 2015 21:59:19 +0000 Subject: [PATCH] Export mg_url_decode() to public PUBLISHED_FROM=442534f52992be612a98a549e5ab2191081a9d52 --- mongoose.c | 4 ++-- mongoose.h | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/mongoose.c b/mongoose.c index 238f7961..8d0e290d 100644 --- a/mongoose.c +++ b/mongoose.c @@ -4851,8 +4851,8 @@ static void remove_double_dots(char *s) { #endif -static int mg_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') diff --git a/mongoose.h b/mongoose.h index e5ce1800..f94d475a 100644 --- a/mongoose.h +++ b/mongoose.h @@ -1690,6 +1690,19 @@ size_t mg_parse_multipart(const char *buf, size_t buf_len, char *var_name, */ int mg_get_http_var(const struct mg_str *, const char *, char *dst, size_t); +/* + * Decode URL-encoded string. + * + * Source string is specified by (`src`, `src_len`), and destination is + * (`dst`, `dst_len`). If `is_form_url_encoded` is non-zero, then + * `+` character is decoded as a blank space character. This function + * guarantees to `\0`-terminate the destination. If destination is too small, + * then source string is partially decoded and `-1` is returned. Otherwise, + * a length of decoded string is returned, not counting final `\0`. + */ +int mg_url_decode(const char *src, int src_len, char *dst, int dst_len, + int is_form_url_encoded); + /* Create Digest authentication header for client request. */ int mg_http_create_digest_auth_header(char *buf, size_t buf_len, const char *method, const char *uri,