Use escape utility from html rather than cgi module
This commit is contained in:
parent
e5591da496
commit
e355a93dc1
@ -24,7 +24,7 @@
|
||||
Provide a simplified table creation interface
|
||||
"""
|
||||
|
||||
import cgi
|
||||
from html import escape
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.sgettext
|
||||
from ..lib import (Person, Family, Event, Source, Place, Citation,
|
||||
@ -153,7 +153,7 @@ class SimpleTable(object):
|
||||
if item.get_valid():
|
||||
if item.format:
|
||||
self.set_cell_markup(col, row,
|
||||
item.format % cgi.escape(text))
|
||||
item.format % escape(text))
|
||||
self.row_sort_val(col, item.sortval)
|
||||
else:
|
||||
# sort before others:
|
||||
@ -161,7 +161,7 @@ class SimpleTable(object):
|
||||
# give formatted version:
|
||||
invalid_date_format = config.get('preferences.invalid-date-format')
|
||||
self.set_cell_markup(col, row,
|
||||
invalid_date_format % cgi.escape(text))
|
||||
invalid_date_format % escape(text))
|
||||
if (self._link_col == col or link is None):
|
||||
link = ('Date', item)
|
||||
elif isinstance(item, Span):
|
||||
@ -261,7 +261,7 @@ class SimpleTable(object):
|
||||
elif y in self._cell_markup[x]:
|
||||
return self._cell_markup[x][y]
|
||||
else:
|
||||
return cgi.escape(data)
|
||||
return escape(data)
|
||||
else:
|
||||
if y is None:
|
||||
return False # no markup for this column
|
||||
|
@ -28,7 +28,7 @@ recompute
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from cgi import escape
|
||||
from html import escape
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -73,17 +73,17 @@ class FormattingHelper(object):
|
||||
text = ""
|
||||
marriage = get_marriage_or_fallback(self.dbstate.db, family)
|
||||
if marriage and use_markup and marriage.get_type() != EventType.MARRIAGE:
|
||||
mdate = "<i>%s %s</i>" % (marriage.get_type().get_abbreviation(),
|
||||
mdate = "<i>%s %s</i>" % (marriage.get_type().get_abbreviation(),
|
||||
escape(get_date(marriage)))
|
||||
mplace = "<i>%s</i>" % escape(self.get_place_name(marriage.get_place_handle()))
|
||||
name = "<i>%s</i>" % str(marriage.get_type())
|
||||
elif marriage and use_markup:
|
||||
mdate = "%s %s" % (marriage.get_type().get_abbreviation(),
|
||||
mdate = "%s %s" % (marriage.get_type().get_abbreviation(),
|
||||
escape(get_date(marriage)))
|
||||
mplace = escape(self.get_place_name(marriage.get_place_handle()))
|
||||
name = str(marriage.get_type())
|
||||
elif marriage:
|
||||
mdate = "%s %s" % (marriage.get_type().get_abbreviation(),
|
||||
mdate = "%s %s" % (marriage.get_type().get_abbreviation(),
|
||||
get_date(marriage))
|
||||
mplace = self.get_place_name(marriage.get_place_handle())
|
||||
name = str(marriage.get_type())
|
||||
@ -149,28 +149,28 @@ class FormattingHelper(object):
|
||||
if line_count >= 3:
|
||||
birth = get_birth_or_fallback(self.dbstate.db, person)
|
||||
if birth and use_markup and birth.get_type() != EventType.BIRTH:
|
||||
bdate = "<i>%s</i>" % escape(get_date(birth))
|
||||
bdate = "<i>%s</i>" % escape(get_date(birth))
|
||||
bplace = "<i>%s</i>" % escape(self.get_place_name(
|
||||
birth.get_place_handle()))
|
||||
elif birth and use_markup:
|
||||
bdate = escape(get_date(birth))
|
||||
bdate = escape(get_date(birth))
|
||||
bplace = escape(self.get_place_name(birth.get_place_handle()))
|
||||
elif birth:
|
||||
bdate = get_date(birth)
|
||||
bdate = get_date(birth)
|
||||
bplace = self.get_place_name(birth.get_place_handle())
|
||||
else:
|
||||
bdate = ""
|
||||
bplace = ""
|
||||
death = get_death_or_fallback(self.dbstate.db, person)
|
||||
if death and use_markup and death.get_type() != EventType.DEATH:
|
||||
ddate = "<i>%s</i>" % escape(get_date(death))
|
||||
ddate = "<i>%s</i>" % escape(get_date(death))
|
||||
dplace = "<i>%s</i>" % escape(self.get_place_name(
|
||||
death.get_place_handle()))
|
||||
elif death and use_markup:
|
||||
ddate = escape(get_date(death))
|
||||
ddate = escape(get_date(death))
|
||||
dplace = escape(self.get_place_name(death.get_place_handle()))
|
||||
elif death:
|
||||
ddate = get_date(death)
|
||||
ddate = get_date(death)
|
||||
dplace = self.get_place_name(death.get_place_handle())
|
||||
else:
|
||||
ddate = ""
|
||||
|
@ -24,7 +24,7 @@
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import Gtk
|
||||
import cgi
|
||||
from html import escape
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -76,7 +76,7 @@ class ChildModel(Gtk.ListStore):
|
||||
if birth.get_type() == EventType.BIRTH:
|
||||
return get_date(birth)
|
||||
else:
|
||||
return '<i>%s</i>' % cgi.escape(get_date(birth))
|
||||
return '<i>%s</i>' % escape(get_date(birth))
|
||||
else:
|
||||
return ""
|
||||
|
||||
@ -99,7 +99,7 @@ class ChildModel(Gtk.ListStore):
|
||||
if death.get_type() == EventType.DEATH:
|
||||
return get_date(death)
|
||||
else:
|
||||
return '<i>%s</i>' % cgi.escape(get_date(death))
|
||||
return '<i>%s</i>' % escape(get_date(death))
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
@ -38,7 +38,7 @@ from gi.repository import Pango
|
||||
WEIGHT_NORMAL = Pango.Weight.NORMAL
|
||||
WEIGHT_BOLD = Pango.Weight.BOLD
|
||||
|
||||
import cgi
|
||||
from html import escape
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -145,7 +145,7 @@ class EventRefModel(Gtk.TreeStore):
|
||||
event = self.db.get_event_from_handle(event_ref.ref)
|
||||
retval = get_date(event)
|
||||
if not get_date_valid(event):
|
||||
return invalid_date_format % cgi.escape(retval)
|
||||
return invalid_date_format % escape(retval)
|
||||
else:
|
||||
return retval
|
||||
|
||||
|
@ -28,7 +28,7 @@ CitationBaseModel classes for GRAMPS.
|
||||
# python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import cgi
|
||||
from html import escape
|
||||
import logging
|
||||
log = logging.getLogger(".")
|
||||
LOG = logging.getLogger(".citation")
|
||||
@ -90,7 +90,7 @@ class CitationBaseModel(object):
|
||||
citation.unserialize(data)
|
||||
date_str = get_date(citation)
|
||||
if date_str != "":
|
||||
retval = cgi.escape(date_str)
|
||||
retval = escape(date_str)
|
||||
if not get_date_valid(citation):
|
||||
return INVALID_DATE_FORMAT % retval
|
||||
else:
|
||||
|
@ -23,7 +23,7 @@
|
||||
# python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import cgi
|
||||
from html import escape
|
||||
import logging
|
||||
log = logging.getLogger(".")
|
||||
|
||||
@ -149,7 +149,7 @@ class EventModel(FlatBaseModel):
|
||||
event.unserialize(data)
|
||||
date_str = get_date(event)
|
||||
if date_str != "":
|
||||
retval = cgi.escape(date_str)
|
||||
retval = escape(date_str)
|
||||
if not get_date_valid(event):
|
||||
return INVALID_DATE_FORMAT % retval
|
||||
else:
|
||||
|
@ -44,7 +44,7 @@ import math
|
||||
import colorsys
|
||||
import sys
|
||||
import pickle
|
||||
from cgi import escape
|
||||
from html import escape
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -42,7 +42,7 @@ import cairo
|
||||
import math
|
||||
import colorsys
|
||||
import pickle
|
||||
from cgi import escape
|
||||
from html import escape
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -27,7 +27,7 @@ __all__ = ["LinkLabel", "EditLabel", "BasicLabel", "GenderLabel",
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import os
|
||||
import cgi
|
||||
from html import escape
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
import logging
|
||||
@ -112,7 +112,7 @@ class LinkLabel(Gtk.EventBox):
|
||||
else:
|
||||
raise AttributeError("invalid theme: '%s'" % theme)
|
||||
|
||||
self.orig_text = cgi.escape(label[0])
|
||||
self.orig_text = escape(label[0])
|
||||
self.gender = label[1]
|
||||
self.decoration = format
|
||||
text = '<span %s>%s</span>' % (self.decoration, self.orig_text)
|
||||
|
@ -22,7 +22,7 @@
|
||||
# Python modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import cgi
|
||||
from html import escape
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -196,11 +196,11 @@ class PedigreeGramplet(Gramplet):
|
||||
if birth and birth.get_type() != EventType.BIRTH:
|
||||
sdate = get_date(birth)
|
||||
if sdate:
|
||||
bdate = "<i>%s</i>" % cgi.escape(sdate)
|
||||
bdate = "<i>%s</i>" % escape(sdate)
|
||||
else:
|
||||
bdate = ""
|
||||
elif birth:
|
||||
bdate = cgi.escape(get_date(birth))
|
||||
bdate = escape(get_date(birth))
|
||||
else:
|
||||
bdate = ""
|
||||
|
||||
@ -208,11 +208,11 @@ class PedigreeGramplet(Gramplet):
|
||||
if death and death.get_type() != EventType.DEATH:
|
||||
sdate = get_date(death)
|
||||
if sdate:
|
||||
ddate = "<i>%s</i>" % cgi.escape(sdate)
|
||||
ddate = "<i>%s</i>" % escape(sdate)
|
||||
else:
|
||||
ddate = ""
|
||||
elif death:
|
||||
ddate = cgi.escape(get_date(death))
|
||||
ddate = escape(get_date(death))
|
||||
else:
|
||||
ddate = ""
|
||||
|
||||
|
@ -33,7 +33,7 @@ _ = glocale.translation.gettext
|
||||
import operator
|
||||
from gi.repository import Gtk
|
||||
from math import *
|
||||
import cgi
|
||||
from html import escape
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -249,11 +249,11 @@ class GeoClose(GeoGraphyView):
|
||||
if birth and birth.get_type() != EventType.BIRTH:
|
||||
sdate = get_date(birth)
|
||||
if sdate:
|
||||
bdate = "<i>%s</i>" % cgi.escape(sdate)
|
||||
bdate = "<i>%s</i>" % escape(sdate)
|
||||
else:
|
||||
bdate = ""
|
||||
elif birth:
|
||||
bdate = cgi.escape(get_date(birth))
|
||||
bdate = escape(get_date(birth))
|
||||
else:
|
||||
bdate = ""
|
||||
return bdate
|
||||
@ -266,11 +266,11 @@ class GeoClose(GeoGraphyView):
|
||||
if death and death.get_type() != EventType.DEATH:
|
||||
sdate = get_date(death)
|
||||
if sdate:
|
||||
ddate = "<i>%s</i>" % cgi.escape(sdate)
|
||||
ddate = "<i>%s</i>" % escape(sdate)
|
||||
else:
|
||||
ddate = ""
|
||||
elif death:
|
||||
ddate = cgi.escape(get_date(death))
|
||||
ddate = escape(get_date(death))
|
||||
else:
|
||||
ddate = ""
|
||||
return ddate
|
||||
|
@ -27,7 +27,7 @@
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from cgi import escape
|
||||
from html import escape
|
||||
import math
|
||||
import os
|
||||
import pickle
|
||||
|
@ -30,7 +30,7 @@ Relationship View
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.sgettext
|
||||
ngettext = glocale.translation.ngettext # else "nearby" comments are ignored
|
||||
import cgi
|
||||
from html import escape
|
||||
import pickle
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -206,7 +206,7 @@ class RelationshipView(NavigationView):
|
||||
|
||||
def person_update(self, handle_list):
|
||||
if self.active:
|
||||
person = self.get_active()
|
||||
person = self.get_active()
|
||||
if person:
|
||||
while not self.change_person(person):
|
||||
pass
|
||||
@ -219,7 +219,7 @@ class RelationshipView(NavigationView):
|
||||
"""Large change to person database"""
|
||||
if self.active:
|
||||
self.bookmarks.redraw()
|
||||
person = self.get_active()
|
||||
person = self.get_active()
|
||||
if person:
|
||||
while not self.change_person(person):
|
||||
pass
|
||||
@ -230,7 +230,7 @@ class RelationshipView(NavigationView):
|
||||
|
||||
def family_update(self, handle_list):
|
||||
if self.active:
|
||||
person = self.get_active()
|
||||
person = self.get_active()
|
||||
if person:
|
||||
while not self.change_person(person):
|
||||
pass
|
||||
@ -241,7 +241,7 @@ class RelationshipView(NavigationView):
|
||||
|
||||
def family_add(self, handle_list):
|
||||
if self.active:
|
||||
person = self.get_active()
|
||||
person = self.get_active()
|
||||
if person:
|
||||
while not self.change_person(person):
|
||||
pass
|
||||
@ -252,7 +252,7 @@ class RelationshipView(NavigationView):
|
||||
|
||||
def family_delete(self, handle_list):
|
||||
if self.active:
|
||||
person = self.get_active()
|
||||
person = self.get_active()
|
||||
if person:
|
||||
while not self.change_person(person):
|
||||
pass
|
||||
@ -263,7 +263,7 @@ class RelationshipView(NavigationView):
|
||||
|
||||
def family_rebuild(self):
|
||||
if self.active:
|
||||
person = self.get_active()
|
||||
person = self.get_active()
|
||||
if person:
|
||||
while not self.change_person(person):
|
||||
pass
|
||||
@ -558,7 +558,7 @@ class RelationshipView(NavigationView):
|
||||
# name and edit button
|
||||
name = name_displayer.display(person)
|
||||
fmt = '<span size="larger" weight="bold">%s</span>'
|
||||
text = fmt % cgi.escape(name)
|
||||
text = fmt % escape(name)
|
||||
label = widgets.DualMarkupLabel(text, _GenderCode[person.gender],
|
||||
x_align=1)
|
||||
if self._config.get('preferences.releditbtn'):
|
||||
@ -740,7 +740,7 @@ class RelationshipView(NavigationView):
|
||||
Shows following elements:
|
||||
(collapse/expand arrow, Parents/Family title label, Family gramps_id, and add-choose-edit-delete buttons)
|
||||
"""
|
||||
msg = '<span style="italic" weight="heavy">%s</span>' % cgi.escape(title)
|
||||
msg = '<span style="italic" weight="heavy">%s</span>' % escape(title)
|
||||
hbox = Gtk.Box()
|
||||
label = widgets.MarkupLabel(msg, x_align=1)
|
||||
# Draw the collapse/expand button:
|
||||
@ -1012,7 +1012,7 @@ class RelationshipView(NavigationView):
|
||||
else:
|
||||
format = "%s"
|
||||
|
||||
label = widgets.MarkupLabel(format % cgi.escape(title),
|
||||
label = widgets.MarkupLabel(format % escape(title),
|
||||
x_align=1, y_align=0)
|
||||
if self._config.get('preferences.releditbtn'):
|
||||
label.set_padding(0, 5)
|
||||
@ -1111,7 +1111,7 @@ class RelationshipView(NavigationView):
|
||||
else:
|
||||
format = "%s"
|
||||
|
||||
lbl = widgets.MarkupLabel(format % cgi.escape(title),
|
||||
lbl = widgets.MarkupLabel(format % escape(title),
|
||||
x_align=1, y_align=.5)
|
||||
if self._config.get('preferences.releditbtn'):
|
||||
lbl.set_padding(0, 5)
|
||||
@ -1201,11 +1201,11 @@ class RelationshipView(NavigationView):
|
||||
if birth and birth.get_type() != EventType.BIRTH:
|
||||
sdate = get_date(birth)
|
||||
if sdate:
|
||||
bdate = "<i>%s</i>" % cgi.escape(sdate)
|
||||
bdate = "<i>%s</i>" % escape(sdate)
|
||||
else:
|
||||
bdate = ""
|
||||
elif birth:
|
||||
bdate = cgi.escape(get_date(birth))
|
||||
bdate = escape(get_date(birth))
|
||||
else:
|
||||
bdate = ""
|
||||
|
||||
@ -1213,11 +1213,11 @@ class RelationshipView(NavigationView):
|
||||
if death and death.get_type() != EventType.DEATH:
|
||||
sdate = get_date(death)
|
||||
if sdate:
|
||||
ddate = "<i>%s</i>" % cgi.escape(sdate)
|
||||
ddate = "<i>%s</i>" % escape(sdate)
|
||||
else:
|
||||
ddate = ""
|
||||
elif death:
|
||||
ddate = cgi.escape(get_date(death))
|
||||
ddate = escape(get_date(death))
|
||||
else:
|
||||
ddate = ""
|
||||
|
||||
@ -1292,7 +1292,7 @@ class RelationshipView(NavigationView):
|
||||
pass
|
||||
|
||||
def write_relationship(self, box, family):
|
||||
msg = _('Relationship type: %s') % cgi.escape(str(family.get_relationship()))
|
||||
msg = _('Relationship type: %s') % escape(str(family.get_relationship()))
|
||||
box.add(widgets.MarkupLabel(msg))
|
||||
|
||||
def write_relationship_events(self, vbox, family):
|
||||
|
Loading…
Reference in New Issue
Block a user