[FIX] report_sxw: fix printing odt/sxw reports after regression from fix for bug 670778
The original fix introduced a safety mechanism for avoiding transmission of invalid binary data via XML-RPC, but caused an issue for binary function fields that do not carry data as base64. This patch fixes this problem with the printing of odt/sxw reports (via odt2odt) which does rely on non-base64 binary data for the sxw content. By re-decoding the unicode-wrapped binary data using the pass-through charset latin1 we are sure to restore the original byte values, hence the original file content. bzr revid: odo@openerp.com-20110104115419-fa4pv1dc63f83dxi
This commit is contained in:
parent
4ae76de3de
commit
15c38f45df
|
@ -679,7 +679,7 @@ def get_nice_size(a):
|
|||
def sanitize_binary_value(dict_item):
|
||||
# binary fields should be 7-bit ASCII base64-encoded data,
|
||||
# but we do additional sanity checks to make sure the values
|
||||
# will are not something else that won't pass via xmlrpc
|
||||
# are not something else that won't pass via xmlrpc
|
||||
index, value = dict_item
|
||||
if isinstance(value, (xmlrpclib.Binary, tuple, list, dict)):
|
||||
# these builtin types are meant to pass untouched
|
||||
|
@ -703,7 +703,7 @@ def sanitize_binary_value(dict_item):
|
|||
# Note: when this happens, decoding on the other endpoint
|
||||
# is not likely to produce the expected output, but this is
|
||||
# just a safety mechanism (in these cases base64 data or
|
||||
# xmlrpc.Binary values should be used instead
|
||||
# xmlrpc.Binary values should be used instead)
|
||||
return index, tools.ustr(value)
|
||||
|
||||
|
||||
|
|
|
@ -518,7 +518,14 @@ class report_sxw(report_rml, preprocess.report):
|
|||
context = context.copy()
|
||||
report_type = report_xml.report_type
|
||||
context['parents'] = sxw_parents
|
||||
sxw_io = StringIO.StringIO(report_xml.report_sxw_content)
|
||||
|
||||
# if binary content was passed as unicode, we must
|
||||
# re-encode it as a 8-bit string using the pass-through
|
||||
# 'latin1' encoding, to restore the original byte values.
|
||||
# See also osv.fields.sanitize_binary_value()
|
||||
binary_report_content = report_xml.report_sxw_content.encode("latin1")
|
||||
|
||||
sxw_io = StringIO.StringIO(binary_report_content)
|
||||
sxw_z = zipfile.ZipFile(sxw_io, mode='r')
|
||||
rml = sxw_z.read('content.xml')
|
||||
meta = sxw_z.read('meta.xml')
|
||||
|
|
Loading…
Reference in New Issue