X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Futils.py;h=47c80f3c137975468569f7b8cb354688448edfce;hb=d1d337ac1162793402ec207082be1161458b193d;hp=fc1465d1b689bf8495e741d2ae355e57d924ba82;hpb=f8996e240d9d0278bce098e23be63db0bcc6fbee;p=dak.git diff --git a/daklib/utils.py b/daklib/utils.py index fc1465d1..47c80f3c 100755 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -50,6 +50,9 @@ re_verwithext = re.compile(r"^(\d+)(?:\.(\d+))(?:\s+\((\S+)\))?$") re_srchasver = re.compile(r"^(\S+)\s+\((\S+)\)$") +html_escaping = {'"':'"', '&':'&', '<':'<', '>':'>'} +re_html_escaping = re.compile('|'.join(map(re.escape, html_escaping.keys()))) + default_config = "/etc/dak/dak.conf" default_apt_config = "/etc/dak/apt.conf" @@ -62,6 +65,11 @@ known_hashes = [("sha1", apt_pkg.sha1sum, (1, 8)), ################################################################################ +def html_escape(s): + return re_html_escaping.sub(lambda x: html_escaping.get(x.group(0)), s) + +################################################################################ + def open_file(filename, mode='r'): try: f = open(filename, mode)