]> granicus.if.org Git - libevent/commitdiff
Test: decoding just part of string with evhttp_decode_uri_internal()
authorAzat Khuzhin <a3at.mail@gmail.com>
Fri, 1 Mar 2013 08:01:42 +0000 (12:01 +0400)
committerAzat Khuzhin <a3at.mail@gmail.com>
Fri, 1 Mar 2013 08:02:54 +0000 (12:02 +0400)
test/regress_http.c

index 3ed314a030f4f60c751670dc7e2504d6fd8d97b5..70b40d17f335c2ff37479699fe9148f5f2933c85 100644 (file)
@@ -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",