2006-12-11 Don Allingham <don@gramps-project.org>

* src/GrampsDb/_WriteXML.py: handle XML escapes
	* src/DisplayModels/_BaseModel.py: handle ignored values in filtering



svn: r7782
This commit is contained in:
Don Allingham 2006-12-11 21:09:25 +00:00
parent 2cea5a95f4
commit 9df661af87
3 changed files with 29 additions and 17 deletions

View File

@ -1,3 +1,7 @@
2006-12-11 Don Allingham <don@gramps-project.org>
* src/GrampsDb/_WriteXML.py: handle XML escapes
* src/DisplayModels/_BaseModel.py: handle ignored values in filtering
2006-12-10 Martin Hawlisch <Martin.Hawlisch@gmx.de> 2006-12-10 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/DataViews/_RelationView.py (change_person): Break endless loop * src/DataViews/_RelationView.py (change_person): Break endless loop
by passing the return values from _change_person. by passing the return values from _change_person.

View File

@ -114,9 +114,11 @@ class BaseModel(gtk.GenericTreeModel):
if self.db.is_open(): if self.db.is_open():
if self.search: if self.search:
self.datalist = [h for h in self.sort_keys()\ self.datalist = [h for h in self.sort_keys()\
if self.search.match(h) and h not in self.skip and h != ignore] if self.search.match(h) and \
h not in self.skip and h != ignore]
else: else:
self.datalist = [h for h in self.sort_keys() if h not in self.skip and h != ignore] self.datalist = [h for h in self.sort_keys() \
if h not in self.skip and h != ignore]
i = 0 i = 0
self.indexlist = {} self.indexlist = {}
for key in self.datalist: for key in self.datalist:
@ -130,9 +132,12 @@ class BaseModel(gtk.GenericTreeModel):
def _rebuild_filter(self, ignore=None): def _rebuild_filter(self, ignore=None):
if self.db.is_open(): if self.db.is_open():
if self.search: if self.search:
self.datalist = self.search.apply(self.db, [ k for k in self.sort_keys() if k != ignore]) self.datalist = self.search.apply(self.db,
[ k for k in self.sort_keys()\
if k != ignore])
else: else:
self.datalist = self.sort_keys() self.datalist = [ k for k in self.sort_keys() \
if k != ignore ]
i = 0 i = 0
self.indexlist = {} self.indexlist = {}

View File

@ -34,6 +34,7 @@ import time
import shutil import shutil
import os import os
import codecs import codecs
from xml.sax.saxutils import escape
from gettext import gettext as _ from gettext import gettext as _
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -75,6 +76,11 @@ _xml_version = "1.1.3"
# table for skipping control chars from XML # table for skipping control chars from XML
strip_dict = dict.fromkeys(range(9)+range(12,20)) strip_dict = dict.fromkeys(range(9)+range(12,20))
def escxml(d):
return esacpe(d, { '"' : '&quot;' } )
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# #
@ -372,10 +378,7 @@ class XmlWriter(UpdateCallback):
except: except:
l = unicode(str(line),errors='replace') l = unicode(str(line),errors='replace')
l = l.strip().translate(strip_dict) l = l.strip().translate(strip_dict)
l = l.replace('&','&amp;') return escxml(l)
l = l.replace('>','&gt;')
l = l.replace('<','&lt;')
return l.replace('"','&quot;')
def write_note(self,val,noteobj,indent=0): def write_note(self,val,noteobj,indent=0):
if not noteobj: if not noteobj:
@ -546,11 +549,11 @@ class XmlWriter(UpdateCallback):
if childref.frel.is_default(): if childref.frel.is_default():
frel_text = '' frel_text = ''
else: else:
frel_text = ' frel="%s"' % childref.frel.xml_str() frel_text = ' frel="%s"' % escxml(childref.frel.xml_str())
if childref.mrel.is_default(): if childref.mrel.is_default():
mrel_text = '' mrel_text = ''
else: else:
mrel_text = ' mrel="%s"' % childref.mrel.xml_str() mrel_text = ' mrel="%s"' % escxml(childref.mrel.xml_str())
sreflist = childref.get_source_references() sreflist = childref.get_source_references()
if (len(sreflist) == 0) and childref.get_note() =="": if (len(sreflist) == 0) and childref.get_note() =="":
self.write_ref('childref',childref.ref,index,close=True, self.write_ref('childref',childref.ref,index,close=True,
@ -568,7 +571,7 @@ class XmlWriter(UpdateCallback):
return return
sp = " "*index sp = " "*index
priv_text = conf_priv(eventref) priv_text = conf_priv(eventref)
role = eventref.role.xml_str() role = escxml(eventref.role.xml_str())
if role: if role:
role_text = ' role="%s"' % role role_text = ' role="%s"' % role
else: else:
@ -670,7 +673,7 @@ class XmlWriter(UpdateCallback):
sp = " "*index sp = " "*index
marker = obj.get_marker().xml_str() marker = obj.get_marker().xml_str()
if marker: if marker:
marker_text = ' marker="%s"' % marker marker_text = ' marker="%s"' % escxml(marker)
else: else:
marker_text = '' marker_text = ''
priv_text = conf_priv(obj) priv_text = conf_priv(obj)
@ -685,7 +688,7 @@ class XmlWriter(UpdateCallback):
sp = " "*index sp = " "*index
self.write_primary_tag('family',family,index) self.write_primary_tag('family',family,index)
if family: if family:
rel = family.get_relationship().xml_str() rel = escxml(family.get_relationship().xml_str())
if rel != "": if rel != "":
self.g.write(' %s<rel type="%s"/>\n' % (sp,rel) ) self.g.write(' %s<rel type="%s"/>\n' % (sp,rel) )
@ -785,7 +788,7 @@ class XmlWriter(UpdateCallback):
if alternative: if alternative:
self.g.write(' alt="1"') self.g.write(' alt="1"')
if name_type: if name_type:
self.g.write(' type="%s"' % name_type) self.g.write(' type="%s"' % escxml(name_type))
if name.get_privacy() != 0: if name.get_privacy() != 0:
self.g.write(' priv="%d"' % name.get_privacy()) self.g.write(' priv="%d"' % name.get_privacy())
if name.get_sort_as() != 0: if name.get_sort_as() != 0:
@ -875,7 +878,7 @@ class XmlWriter(UpdateCallback):
sp = ' ' * indent sp = ' ' * indent
for attr in list: for attr in list:
self.g.write('%s<attribute%s type="%s" value="%s"' % \ self.g.write('%s<attribute%s type="%s" value="%s"' % \
(sp,conf_priv(attr),attr.get_type().xml_str(), (sp,conf_priv(attr),escxml(attr.get_type().xml_str()),
self.fix(attr.get_value()))) self.fix(attr.get_value())))
slist = attr.get_source_references() slist = attr.get_source_references()
note = attr.get_note() note = attr.get_note()
@ -929,7 +932,7 @@ class XmlWriter(UpdateCallback):
mtype = reporef.media_type.xml_str() mtype = reporef.media_type.xml_str()
if mtype: if mtype:
type_text = ' medium="%s"' % mtype type_text = ' medium="%s"' % escxml(mtype)
else: else:
type_text = '' type_text = ''
@ -948,7 +951,7 @@ class XmlWriter(UpdateCallback):
for url in list: for url in list:
url_type = url.get_type().xml_str() url_type = url.get_type().xml_str()
if url_type: if url_type:
type_text = ' type="%s"' % url_type type_text = ' type="%s"' % escxml(url_type)
else: else:
type_text = '' type_text = ''
priv_text = conf_priv(url) priv_text = conf_priv(url)