summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/file.c1
-rw-r--r--utils/url.c6
-rw-r--r--utils/url.h12
3 files changed, 14 insertions, 5 deletions
diff --git a/utils/file.c b/utils/file.c
index 6224d1c3c..3ec97dec6 100644
--- a/utils/file.c
+++ b/utils/file.c
@@ -138,6 +138,7 @@ static nserror posix_nsurl_to_path(struct nsurl *url, char **path_out)
res = url_unescape(lwc_string_data(urlpath),
lwc_string_length(urlpath),
+ NULL,
&path);
lwc_string_unref(urlpath);
if (res != NSERROR_OK) {
diff --git a/utils/url.c b/utils/url.c
index 3be983d78..9294e3d31 100644
--- a/utils/url.c
+++ b/utils/url.c
@@ -54,7 +54,8 @@ static inline char xdigit_to_hex(char c)
/* exported interface documented in utils/url.h */
-nserror url_unescape(const char *str, size_t length, char **result_out)
+nserror url_unescape(const char *str, size_t length,
+ size_t *length_out, char **result_out)
{
const char *str_end;
size_t new_len;
@@ -106,6 +107,9 @@ nserror url_unescape(const char *str, size_t length, char **result_out)
}
}
+ if (length_out != NULL) {
+ *length_out = new_len;
+ }
*result_out = result;
return NSERROR_OK;
}
diff --git a/utils/url.h b/utils/url.h
index e67d69a4f..07ad1a794 100644
--- a/utils/url.h
+++ b/utils/url.h
@@ -45,11 +45,15 @@ nserror url_escape(const char *unescaped, size_t toskip, bool sptoplus,
/**
* Convert an escaped string to plain.
*
- * \param[in] str String to unescape.
- * \param[in] length Length of string or 0 to use strlen
- * \param[out] result unescaped string owned by caller must be freed with free()
+ * \param[in] str String to unescape.
+ * \param[in] length Length of string or 0 to use strlen.
+ * \param[out] length_out Iff non-NULL, value updated to length of returned
+ * result_out string.
+ * \param[out] result_out Returns unescaped string, owned by caller.
+ * Must be freed with free().
* \return NSERROR_OK on success
*/
-nserror url_unescape(const char *str, size_t length, char **result);
+nserror url_unescape(const char *str, size_t length,
+ size_t *length_out, char **result_out);
#endif