summaryrefslogtreecommitdiff
path: root/utils/url.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2016-08-03 15:04:28 +0100
committerVincent Sanders <vince@kyllikki.org>2016-08-03 15:04:28 +0100
commiteb5e0599afe3bae86a375acea4d8ca106594c45b (patch)
tree7cc7c07e7690e21f9093b14bc5ad78e653f0656a /utils/url.c
parent908db8a51d21163e8c7607538834693b4e2ae490 (diff)
downloadnetsurf-eb5e0599afe3bae86a375acea4d8ca106594c45b.tar.gz
netsurf-eb5e0599afe3bae86a375acea4d8ca106594c45b.tar.bz2
Improve percent escaping testing, parameter checking and documentation
Diffstat (limited to 'utils/url.c')
-rw-r--r--utils/url.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/utils/url.c b/utils/url.c
index 861a62bdc..7a7b7a196 100644
--- a/utils/url.c
+++ b/utils/url.c
@@ -18,8 +18,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * \brief Implementation of URL parsing and joining operations.
+/**
+ * \file
+ * \brief Implementation of URI percent escaping.
+ *
+ * Percent encoding of URI is subject to RFC3986 however this is not
+ * implementing URI behaviour purely the percent encoding so only the
+ * unreserved set is not encoded and arbitrary binary data may be
+ * unescaped.
+ *
+ * \note Earlier RFC (2396, 1738 and 1630) list the tilde ~ character
+ * as special so its handling is ambiguious
*/
#include <ctype.h>
@@ -37,7 +46,7 @@
*
* Must be called with valid hex char, results undefined otherwise.
*
- * \param[in] c char to convert yo value
+ * \param[in] c character to convert to value
* \return the value of c
*/
static inline char xdigit_to_hex(char c)
@@ -61,6 +70,10 @@ nserror url_unescape(const char *str, size_t length,
char *res_pos;
char *result;
+ if ((str == NULL) || (result_out == NULL)) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
if (length == 0) {
length = strlen(str);
}
@@ -121,7 +134,7 @@ nserror url_escape(const char *unescaped, bool sptoplus,
const char *c;
if (unescaped == NULL || result == NULL) {
- return NSERROR_NOT_FOUND;
+ return NSERROR_BAD_PARAMETER;
}
len = strlen(unescaped);