Permalink
Browse files

Test: decoding just part of string with evhttp_decode_uri_internal()

  • Loading branch information...
1 parent de8101a commit 13676535c83448b957ae00772c13f823cc9d3503 @azat azat committed Mar 1, 2013
Showing with 10 additions and 0 deletions.
  1. +10 −0 test/regress_http.c
View
@@ -2396,6 +2396,7 @@ http_uriencode_test(void *ptr)
{
char *s=NULL, *s2=NULL;
size_t sz;
+ int bytes_decoded;
#define ENC(from,want,plus) do { \
s = evhttp_uriencode((from), -1, (plus)); \
@@ -2452,6 +2453,15 @@ http_uriencode_test(void *ptr)
free(s);
s = NULL;
+ /* Now try decoding just part of string. */
+ s = malloc(6 + 1 /* NUL byte */);
+ bytes_decoded = evhttp_decode_uri_internal("hello%20%20", 6, s, 0);
+ tt_assert(s);
+ tt_int_op(bytes_decoded,==,6);
+ tt_str_op(s,==,"hello%");
+ free(s);
+ s = NULL;
+
/* Now try out some decoding cases that we don't generate with
* encode_uri: Make sure that malformed stuff doesn't crash... */
DEC("%%xhello th+ere \xff",

0 comments on commit 1367653

Please sign in to comment.