On Mon, May 05, 2008 at 10:41:00AM +0100, Jeremy Henty wrote:
Html_build_query_data() and Html_make_multipart_boundary() iterate over a Dlist while destructively modifying it *and* recalculating the list length each time, so the iteration terminates prematurely. This makes Html_build_query_data() mangle the result when an input returns multiple values: half of the values get attached to the next input!
This patch fixes the problem by caching the length of the list before modifying it so that the entire list is processed.
Cool, I also tried to hook up your ListResource code in html.cc, but could not find the reason why some of the selected items were missing on submit. Regards, Johannes
Regards,
Jeremy Henty
diff -pru -- 00_pre/src/html.cc 01_post/src/html.cc --- 00_pre/src/html.cc 2008-05-02 18:25:13.000000000 +0100 +++ 01_post/src/html.cc 2008-05-05 10:10:18.000000000 +0100 @@ -4191,7 +4191,8 @@ static char *Html_make_multipart_boundar dStr_free(dstr, 1); } } - for (int i = 0; i < dList_length(values); i++) { + int length = dList_length(values); + for (int i = 0; i < length; i++) { dstr = (Dstr *) dList_nth_data(values, 0); dList_remove(values, dstr); if (input->type != DILLO_HTML_INPUT_FILE) @@ -4283,8 +4284,8 @@ static Dstr *Html_build_query_data(Dillo Html_urlencode_append(DataStr, val->str); dStr_free(val, 1); } else { - int i; - for (i = 0; i < dList_length(values); i++) { + int length = dList_length(values), i; + for (i = 0; i < length; i++) { Dstr *val = (Dstr *) dList_nth_data(values, 0); dList_remove(values, val); val = Html_encode_text(encoder, &val);
_______________________________________________ Dillo-dev mailing list Dillo-dev@dillo.org http://lists.auriga.wearlab.de/cgi-bin/mailman/listinfo/dillo-dev