1.1 --- a/XSLForms/Resources.py Thu Aug 11 19:11:22 2005 +0000
1.2 +++ b/XSLForms/Resources.py Thu Aug 11 19:11:58 2005 +0000
1.3 @@ -78,26 +78,21 @@
1.4 document_resources = {}
1.5 resource_dir = None
1.6
1.7 - def get_fields_from_body(self, trans, encoding):
1.8 + def clean_parameters(self, parameters):
1.9
1.10 """
1.11 - From the given transaction 'trans' and using the stated text 'encoding'
1.12 - get the field values from the request body and return a dictionary
1.13 - mapping field names to lists of such values.
1.14 + Workaround stray zero value characters from Konqueror in XMLHttpRequest
1.15 + communications.
1.16 """
1.17
1.18 - text = trans.get_request_stream().read().decode(encoding)
1.19 - parameters = {}
1.20 - for text_line in text.split("\r\n"):
1.21 - text_parts = text_line.split("=")
1.22 - text_name, text_value = text_parts[0], "=".join(text_parts[1:])
1.23 - if not parameters.has_key(text_name):
1.24 - parameters[text_name] = []
1.25 - # NOTE: Workaround from posted text.
1.26 - if len(text_value) > 0 and text_value[-1] == "\x00":
1.27 - text_value = text_value[:-1]
1.28 - parameters[text_name].append(text_value)
1.29 - return parameters
1.30 + for name, values in parameters.items():
1.31 + new_values = []
1.32 + for value in values:
1.33 + if value.endswith("\x00"):
1.34 + new_values.append(value[:-1])
1.35 + else:
1.36 + new_values.append(value)
1.37 + parameters[name] = new_values
1.38
1.39 def prepare_output(self, output_identifier):
1.40
1.41 @@ -229,15 +224,10 @@
1.42 # Get the fields from the request body.
1.43
1.44 form = XSLForms.Fields.Form(encoding=self.encoding, values_are_lists=1)
1.45 -
1.46 - # Handle requests for in-page updates.
1.47 + parameters = trans.get_fields_from_body(self.encoding)
1.48
1.49 - if in_page_resource in self.in_page_resources.keys():
1.50 - parameters = self.get_fields_from_body(trans, self.encoding)
1.51 - else:
1.52 - parameters = trans.get_fields_from_body(self.encoding)
1.53 -
1.54 - # Get the XML representation of the request.
1.55 + # NOTE: Konqueror workaround.
1.56 + self.clean_parameters(parameters)
1.57
1.58 form.set_parameters(parameters)
1.59
2.1 --- a/examples/Common/Configurator/Resources/scripts/XSLForms.js Thu Aug 11 19:11:22 2005 +0000
2.2 +++ b/examples/Common/Configurator/Resources/scripts/XSLForms.js Thu Aug 11 19:11:58 2005 +0000
2.3 @@ -17,6 +17,7 @@
2.4
2.5 // Load the remote document with the given parameters sent as text in the request body.
2.6
2.7 + xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2.8 xmlhttp.send(requestBody);
2.9
2.10 // Parse the result document.
2.11 @@ -73,12 +74,12 @@
2.12 for (var opt = 0; opt < fieldNodes[v].options.length; opt++) {
2.13 if (fieldNodes[v].options[opt].selected) {
2.14 fieldValue = fieldNodes[v].options[opt].value;
2.15 - requestBody += ("\r\n" + fieldName + "=" + fieldValue);
2.16 + requestBody += ("&" + fieldName + "=" + fieldValue);
2.17 }
2.18 }
2.19 } else {
2.20 fieldValue = fieldNodes[v].value;
2.21 - requestBody += ("\r\n" + fieldName + "=" + fieldValue);
2.22 + requestBody += ("&" + fieldName + "=" + fieldValue);
2.23 }
2.24 }
2.25
3.1 --- a/examples/Common/VerySimple/Resources/scripts/XSLForms.js Thu Aug 11 19:11:22 2005 +0000
3.2 +++ b/examples/Common/VerySimple/Resources/scripts/XSLForms.js Thu Aug 11 19:11:58 2005 +0000
3.3 @@ -17,6 +17,7 @@
3.4
3.5 // Load the remote document with the given parameters sent as text in the request body.
3.6
3.7 + xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
3.8 xmlhttp.send(requestBody);
3.9
3.10 // Parse the result document.
3.11 @@ -73,12 +74,12 @@
3.12 for (var opt = 0; opt < fieldNodes[v].options.length; opt++) {
3.13 if (fieldNodes[v].options[opt].selected) {
3.14 fieldValue = fieldNodes[v].options[opt].value;
3.15 - requestBody += ("\r\n" + fieldName + "=" + fieldValue);
3.16 + requestBody += ("&" + fieldName + "=" + fieldValue);
3.17 }
3.18 }
3.19 } else {
3.20 fieldValue = fieldNodes[v].value;
3.21 - requestBody += ("\r\n" + fieldName + "=" + fieldValue);
3.22 + requestBody += ("&" + fieldName + "=" + fieldValue);
3.23 }
3.24 }
3.25