GeoView : escape '"' and '&' characters

svn: r14330
This commit is contained in:
Serge Noiraud 2010-02-12 09:51:18 +00:00
parent 051cd9efe1
commit f731980e8e

View File

@ -228,6 +228,14 @@ def _make_callback(func, val):
""" """
return lambda x: func(val) return lambda x: func(val)
def _escape(text):
"""
return the text with some characters translated : " &
"""
text = text.replace('&','\\&')
text = text.replace('"','\\"')
return text
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# GeoView # GeoView
@ -1566,7 +1574,7 @@ class GeoView(HtmlView):
self.mapview.write("my_marker = new Marker(point);") self.mapview.write("my_marker = new Marker(point);")
self.mapview.write("gmarkers[%d]=my_marker;" % ind ) self.mapview.write("gmarkers[%d]=my_marker;" % ind )
self.mapview.write("my_marker.setLabel") self.mapview.write("my_marker.setLabel")
self.mapview.write("(\"%s\");" % mark[0]) self.mapview.write("(\"%s\");" % _escape(mark[0]))
self.yearinmarker.append(mark[7]) self.yearinmarker.append(mark[7])
divclose = False divclose = False
differtype = False differtype = False
@ -1574,25 +1582,25 @@ class GeoView(HtmlView):
savetype = mark[8] savetype = mark[8]
self.mapview.write("my_marker.setInfoBubble(\"<div ") self.mapview.write("my_marker.setInfoBubble(\"<div ")
self.mapview.write("id='geo-info' >") self.mapview.write("id='geo-info' >")
self.mapview.write("%s<br>" % mark[0]) self.mapview.write("%s<br>" % _escape(mark[0]))
if formatype == 1: if formatype == 1:
self.mapview.write("<br>%s" % mark[5]) self.mapview.write("<br>%s" % _escape(mark[5]))
elif formatype == 2: elif formatype == 2:
self.mapview.write("<br>%s - %s" % (mark[7], self.mapview.write("<br>%s - %s" % (_escape(mark[7]),
mark[5])) _escape(mark[5])))
elif formatype == 3: elif formatype == 3:
self.mapview.write("<br>%s - %s" % (mark[7], self.mapview.write("<br>%s - %s" % (_escape(mark[7]),
mark[5])) _escape(mark[5])))
elif formatype == 4: elif formatype == 4:
self.mapview.write("<br>%s - %s" % (mark[7], self.mapview.write("<br>%s - %s" % (_escape(mark[7]),
mark[5])) _escape(mark[5])))
else: # This marker already exists. add info. else: # This marker already exists. add info.
if ( mark[8] and savetype != mark[8] ): if ( mark[8] and savetype != mark[8] ):
differtype = True differtype = True
if indm > last: if indm > last:
divclose = True divclose = True
else: else:
self.mapview.write("<br>%s - %s" % (mark[7], mark[5])) self.mapview.write("<br>%s - %s" % (_escape(mark[7]), _escape(mark[5])))
ret = 1 ret = 1
for year in self.yearinmarker: for year in self.yearinmarker:
if year == mark[7]: if year == mark[7]: