# HG changeset patch # User paulb # Date 1123787518 0 # Node ID 92224dcaf7e4337675e84ac56ce8c15b0388d820 # Parent c90cc4f8e35dabe66bfdf5b274dbc493fd86ccab [project @ 2005-08-11 19:11:53 by paulb] Changed the in-page requests to use genuine POST data. diff -r c90cc4f8e35d -r 92224dcaf7e4 XSLForms/Resources.py --- a/XSLForms/Resources.py Thu Aug 11 19:11:22 2005 +0000 +++ b/XSLForms/Resources.py Thu Aug 11 19:11:58 2005 +0000 @@ -78,26 +78,21 @@ document_resources = {} resource_dir = None - def get_fields_from_body(self, trans, encoding): + def clean_parameters(self, parameters): """ - From the given transaction 'trans' and using the stated text 'encoding' - get the field values from the request body and return a dictionary - mapping field names to lists of such values. + Workaround stray zero value characters from Konqueror in XMLHttpRequest + communications. """ - text = trans.get_request_stream().read().decode(encoding) - parameters = {} - for text_line in text.split("\r\n"): - text_parts = text_line.split("=") - text_name, text_value = text_parts[0], "=".join(text_parts[1:]) - if not parameters.has_key(text_name): - parameters[text_name] = [] - # NOTE: Workaround from posted text. - if len(text_value) > 0 and text_value[-1] == "\x00": - text_value = text_value[:-1] - parameters[text_name].append(text_value) - return parameters + for name, values in parameters.items(): + new_values = [] + for value in values: + if value.endswith("\x00"): + new_values.append(value[:-1]) + else: + new_values.append(value) + parameters[name] = new_values def prepare_output(self, output_identifier): @@ -229,15 +224,10 @@ # Get the fields from the request body. form = XSLForms.Fields.Form(encoding=self.encoding, values_are_lists=1) - - # Handle requests for in-page updates. + parameters = trans.get_fields_from_body(self.encoding) - if in_page_resource in self.in_page_resources.keys(): - parameters = self.get_fields_from_body(trans, self.encoding) - else: - parameters = trans.get_fields_from_body(self.encoding) - - # Get the XML representation of the request. + # NOTE: Konqueror workaround. + self.clean_parameters(parameters) form.set_parameters(parameters) diff -r c90cc4f8e35d -r 92224dcaf7e4 examples/Common/Configurator/Resources/scripts/XSLForms.js --- a/examples/Common/Configurator/Resources/scripts/XSLForms.js Thu Aug 11 19:11:22 2005 +0000 +++ b/examples/Common/Configurator/Resources/scripts/XSLForms.js Thu Aug 11 19:11:58 2005 +0000 @@ -17,6 +17,7 @@ // Load the remote document with the given parameters sent as text in the request body. + xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlhttp.send(requestBody); // Parse the result document. @@ -73,12 +74,12 @@ for (var opt = 0; opt < fieldNodes[v].options.length; opt++) { if (fieldNodes[v].options[opt].selected) { fieldValue = fieldNodes[v].options[opt].value; - requestBody += ("\r\n" + fieldName + "=" + fieldValue); + requestBody += ("&" + fieldName + "=" + fieldValue); } } } else { fieldValue = fieldNodes[v].value; - requestBody += ("\r\n" + fieldName + "=" + fieldValue); + requestBody += ("&" + fieldName + "=" + fieldValue); } } diff -r c90cc4f8e35d -r 92224dcaf7e4 examples/Common/VerySimple/Resources/scripts/XSLForms.js --- a/examples/Common/VerySimple/Resources/scripts/XSLForms.js Thu Aug 11 19:11:22 2005 +0000 +++ b/examples/Common/VerySimple/Resources/scripts/XSLForms.js Thu Aug 11 19:11:58 2005 +0000 @@ -17,6 +17,7 @@ // Load the remote document with the given parameters sent as text in the request body. + xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlhttp.send(requestBody); // Parse the result document. @@ -73,12 +74,12 @@ for (var opt = 0; opt < fieldNodes[v].options.length; opt++) { if (fieldNodes[v].options[opt].selected) { fieldValue = fieldNodes[v].options[opt].value; - requestBody += ("\r\n" + fieldName + "=" + fieldValue); + requestBody += ("&" + fieldName + "=" + fieldValue); } } } else { fieldValue = fieldNodes[v].value; - requestBody += ("\r\n" + fieldName + "=" + fieldValue); + requestBody += ("&" + fieldName + "=" + fieldValue); } }