diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-07-09 21:28:40 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-07-09 21:28:40 +0200 |
commit | 8c77370410297ae698a1b034da203fd567867203 (patch) | |
tree | a0aac7efa04c866b6819dde84baa843866d59452 | |
parent | 860b42e9180da4dcd7e8690a3fcdb4e37e5772c5 (diff) | |
download | libmicrohttpd-8c77370410297ae698a1b034da203fd567867203.tar.gz libmicrohttpd-8c77370410297ae698a1b034da203fd567867203.zip |
add MD test for %2 decoding problem in PP
-rw-r--r-- | src/microhttpd/test_postprocessor_md.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/microhttpd/test_postprocessor_md.c b/src/microhttpd/test_postprocessor_md.c index 1e9e4143..bfa2d76a 100644 --- a/src/microhttpd/test_postprocessor_md.c +++ b/src/microhttpd/test_postprocessor_md.c | |||
@@ -103,6 +103,29 @@ post_data_iterator (void *cls, | |||
103 | } | 103 | } |
104 | 104 | ||
105 | 105 | ||
106 | static enum MHD_Result | ||
107 | post_data_iterator2 (void *cls, | ||
108 | enum MHD_ValueKind kind, | ||
109 | const char *key, | ||
110 | const char *filename, | ||
111 | const char *content_type, | ||
112 | const char *transfer_encoding, | ||
113 | const char *data, | ||
114 | uint64_t off, | ||
115 | size_t size) | ||
116 | { | ||
117 | printf ("%s\t%s\n", key, data); | ||
118 | if (0 == strcmp (key, "text")) | ||
119 | { | ||
120 | if ( (10 != size) || | ||
121 | (0 != memcmp (data, "text, text", 10)) ) | ||
122 | exit (5); | ||
123 | found |= 1; | ||
124 | } | ||
125 | return MHD_YES; | ||
126 | } | ||
127 | |||
128 | |||
106 | int | 129 | int |
107 | main (int argc, char *argv[]) | 130 | main (int argc, char *argv[]) |
108 | { | 131 | { |
@@ -128,5 +151,27 @@ main (int argc, char *argv[]) | |||
128 | exit (3); | 151 | exit (3); |
129 | if (found != 15) | 152 | if (found != 15) |
130 | exit (2); | 153 | exit (2); |
154 | |||
155 | found = 0; | ||
156 | postprocessor = malloc (sizeof (struct MHD_PostProcessor) | ||
157 | + 0x1000 + 1); | ||
158 | if (NULL == postprocessor) | ||
159 | return 77; | ||
160 | memset (postprocessor, | ||
161 | 0, | ||
162 | sizeof (struct MHD_PostProcessor) + 0x1000 + 1); | ||
163 | postprocessor->ikvi = post_data_iterator2; | ||
164 | postprocessor->encoding = MHD_HTTP_POST_ENCODING_FORM_URLENCODED; | ||
165 | postprocessor->buffer_size = 0x1000; | ||
166 | postprocessor->state = PP_Init; | ||
167 | postprocessor->skip_rn = RN_Inactive; | ||
168 | MHD_post_process (postprocessor, "text=text%2C+text", 11 + 6); | ||
169 | // MHD_post_process (postprocessor, "text=text%2", 11); | ||
170 | // MHD_post_process (postprocessor, "C+text", 6); | ||
171 | MHD_post_process (postprocessor, "", 0); | ||
172 | MHD_destroy_post_processor (postprocessor); | ||
173 | if (found != 1) | ||
174 | exit (4); | ||
175 | |||
131 | return EXIT_SUCCESS; | 176 | return EXIT_SUCCESS; |
132 | } | 177 | } |