diff --git a/product/ERP5SyncML/Conduit/ERP5Conduit.py b/product/ERP5SyncML/Conduit/ERP5Conduit.py index dd8893e96b0ebc74bb3805d77c71808d30b2527c..2a787cd9eeb440a266b4f9bacb3ec57d68fcbb7e 100644 --- a/product/ERP5SyncML/Conduit/ERP5Conduit.py +++ b/product/ERP5SyncML/Conduit/ERP5Conduit.py @@ -41,6 +41,7 @@ from xml.sax.saxutils import escape, unescape import re import cStringIO from lxml import etree +parser = etree.XMLParser(remove_blank_text=True) from xml.marshal.generic import loads as unmarshaler from zLOG import LOG, INFO, DEBUG @@ -644,7 +645,7 @@ class ERP5Conduit(XMLSyncUtilsMixin): if isinstance(xml, (str, unicode)): if isinstance(xml, unicode): xml = xml.encode('utf-8') - xml = etree.XML(xml) + xml = etree.XML(xml, parser=parser) # If we have the xml from the node erp5, we just take the subnode if xml.tag == 'erp5': xml = xml[0] @@ -850,7 +851,7 @@ class ERP5Conduit(XMLSyncUtilsMixin): """ conflict_list = [] if isinstance(xupdate, (str, unicode)): - xupdate = etree.XML(xupdate) + xupdate = etree.XML(xupdate, parser=parser) #When xupdate mix different object, (like object and his subobject) we need to treat them separatly if self.isMixedXupdate(xupdate): #return to updateNode with only one line diff --git a/product/ERP5SyncML/ERP5SyncMLMobileServer.py b/product/ERP5SyncML/ERP5SyncMLMobileServer.py index c63582b28a82d1e4df9b674522ac251ee3224daa..3d9e9aea0604b99161e1042e1e5dcb5045607f6c 100755 --- a/product/ERP5SyncML/ERP5SyncMLMobileServer.py +++ b/product/ERP5SyncML/ERP5SyncMLMobileServer.py @@ -8,6 +8,7 @@ import socket import time from optparse import OptionParser from lxml import etree +parser = etree.XMLParser(remove_blank_text=True) class OptionParser(OptionParser): @@ -136,7 +137,7 @@ def getClientUrl(text): """ find the client url in the text and return it """ - document = etree.XML(text) + document = etree.XML(text, parser=parser) client_url = '%s' % document.xpath('string(//SyncHdr/Source/LocURI)') return client_url diff --git a/product/ERP5SyncML/SynchronizationTool.py b/product/ERP5SyncML/SynchronizationTool.py index ae42545bc283188fc769616400f5e29a6b8506d5..1b8e50b4a88c6e25d592cfc53d54e59f0b3dbb3a 100644 --- a/product/ERP5SyncML/SynchronizationTool.py +++ b/product/ERP5SyncML/SynchronizationTool.py @@ -61,6 +61,7 @@ from DateTime import DateTime from zLOG import LOG, TRACE, DEBUG, INFO from lxml import etree +parser = etree.XMLParser(remove_blank_text=True) class TimeoutHTTPConnection(httplib.HTTPConnection): """ @@ -1034,7 +1035,7 @@ class SynchronizationTool( SubscriptionSynchronization, if domain.getSyncContentType() == self.CONTENT_TYPE['SYNCML_WBXML']: text = self.wbxml2xml(text) #LOG('readResponse, text after wbxml :\n', TRACE, text) - xml = etree.XML(text) + xml = etree.XML(text, parser=parser) url = self.getTarget(xml) for publication in self.getPublicationList(): if publication.getPublicationUrl() == url and \ diff --git a/product/ERP5SyncML/XMLSyncUtils.py b/product/ERP5SyncML/XMLSyncUtils.py index 7524333101bc682cb46ff62810d2e676cbe4f5af..23120b6ca0fdf6e5e38d0283359bc75d30d17943 100644 --- a/product/ERP5SyncML/XMLSyncUtils.py +++ b/product/ERP5SyncML/XMLSyncUtils.py @@ -36,6 +36,8 @@ from zLOG import LOG, INFO from lxml import etree from lxml.etree import Element from lxml.builder import E +parser = etree.XMLParser(remove_blank_text=True) + from xml.dom import minidom try: @@ -340,7 +342,7 @@ class XMLSyncUtilsMixin(SyncCode): """ data_node = Element('Data') if media_type == self.MEDIA_TYPE['TEXT_XML'] and isinstance(xml_string, str): - data_node.append(etree.XML(xml_string)) + data_node.append(etree.XML(xml_string, parser=parser)) elif media_type == self.MEDIA_TYPE['TEXT_XML'] and \ not isinstance(xml_string, str): #xml_string could be Partial element if partial XML @@ -396,7 +398,7 @@ class XMLSyncUtilsMixin(SyncCode): if not isinstance(xml_string, (str, unicode)): data_node.append(xml_string) else: - data_node.append(etree.XML(xml_string)) + data_node.append(etree.XML(xml_string, parser=parser)) xml = (E.Replace( E.CmdID('%s' % cmd_id), E.Meta( @@ -672,7 +674,7 @@ class XMLSyncUtilsMixin(SyncCode): syncml_data = kw.get('syncml_data','') result = {'finished':1} if isinstance(remote_xml, (str, unicode)): - remote_xml = etree.XML(remote_xml) + remote_xml = etree.XML(remote_xml, parser=parser) if domain.isOneWayFromServer(): #Do not set object_path_list, subscriber send nothing subscriber.setRemainingObjectPathList([]) @@ -968,7 +970,7 @@ class XMLSyncUtilsMixin(SyncCode): data_subnode = partial_data #LOG('applyActionList', DEBUG, 'data_subnode: %s' % data_subnode) if subscriber.getMediaType() == self.MEDIA_TYPE['TEXT_XML']: - data_subnode = etree.XML(data_subnode) + data_subnode = etree.XML(data_subnode, parser=parser) else: if subscriber.getMediaType() != self.MEDIA_TYPE['TEXT_XML']: data_subnode = self.getDataText(action) @@ -1306,7 +1308,7 @@ class XMLSyncUtils(XMLSyncUtilsMixin): domain.activate(activity='SQLQueue', tag=domain.getId(), priority=self.PRIORITY).activateSyncModif( - domain_relative_url = domain.getRelativeUrl(), + domain_relative_url=domain.getRelativeUrl(), remote_xml=remote_xml, subscriber_relative_url=subscriber.getRelativeUrl(), cmd_id=cmd_id, @@ -1384,7 +1386,7 @@ class XMLSyncUtils(XMLSyncUtilsMixin): xml_confirmation = result['xml_confirmation'] cmd_id = result['cmd_id'] cmd_id_before_getsyncmldata = kw['cmd_id_before_getsyncmldata'] - remote_xml = etree.XML(kw['remote_xml']) + remote_xml = etree.XML(kw['remote_xml'], parser=parser) xml_list = kw['xml_list'] has_status_list = kw['has_status_list'] has_response = kw['has_response'] @@ -1501,7 +1503,7 @@ class XMLSyncUtils(XMLSyncUtilsMixin): if xml_client is not None: if isinstance(xml_client, (str, unicode)): - xml_client = etree.XML(xml_client) + xml_client = etree.XML(xml_client, parser=parser) if xml_client.tag != "SyncML": LOG('PubSync', INFO, 'This is not a SyncML Message') raise ValueError, "Sorry, This is not a SyncML Message" @@ -1571,7 +1573,7 @@ class XMLSyncUtils(XMLSyncUtilsMixin): else: xml_client = msg if isinstance(xml_client, (str, unicode)): - xml_client = etree.XML(xml_client) + xml_client = etree.XML(xml_client, parser=parser) status_list = self.getSyncBodyStatusList(xml_client) if status_list: status_code_syncHdr = status_list[0]['code'] @@ -1598,7 +1600,7 @@ class XMLSyncUtils(XMLSyncUtilsMixin): else: response = self.SubSyncModif(subscription, xml_client) else: - response = self.SubSyncModif(subscription, xml_client) + response = self.SubSyncModif(subscription, xml_client) if RESPONSE is not None: RESPONSE.redirect('manageSubscriptions')