diff options
Diffstat (limited to 'Mailman/htmlformat.py')
-rwxr-xr-x | Mailman/htmlformat.py | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/Mailman/htmlformat.py b/Mailman/htmlformat.py index 2387096e..f144c069 100755 --- a/Mailman/htmlformat.py +++ b/Mailman/htmlformat.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2012 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2016 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -32,7 +32,7 @@ import types from Mailman import mm_cfg from Mailman import Utils -from Mailman.i18n import _ +from Mailman.i18n import _, get_translation from Mailman.CSRFcheck import csrf_token @@ -318,6 +318,8 @@ class Document(Container): 'content="text/html; charset=%s">' % charset) if self.title: output.append('%s<TITLE>%s</TITLE>' % (tab, self.title)) + if mm_cfg.WEB_HEAD_ADD: + output.append(mm_cfg.WEB_HEAD_ADD) output.append('%s</HEAD>' % tab) quals = [] # Default link colors @@ -405,13 +407,14 @@ class Center(StdContainer): class Form(Container): def __init__(self, action='', method='POST', encoding=None, - mlist=None, contexts=None, *items): + mlist=None, contexts=None, user=None, *items): apply(Container.__init__, (self,) + items) self.action = action self.method = method self.encoding = encoding self.mlist = mlist self.contexts = contexts + self.user = user def set_action(self, action): self.action = action @@ -426,7 +429,7 @@ class Form(Container): if self.mlist: output = output + \ '<input type="hidden" name="csrf_token" value="%s">\n' \ - % csrf_token(self.mlist, self.contexts) + % csrf_token(self.mlist, self.contexts, self.user) output = output + Container.Format(self, indent+2) output = '%s\n%s</FORM>\n' % (output, spaces) return output @@ -441,6 +444,7 @@ class InputObj: self.kws = kws def Format(self, indent=0): + charset = get_translation().charset() or 'us-ascii' output = ['<INPUT name="%s" type="%s" value="%s"' % (self.name, self.type, self.value)] for item in self.kws.items(): @@ -448,7 +452,10 @@ class InputObj: if self.checked: output.append('CHECKED') output.append('>') - return SPACE.join(output) + ret = SPACE.join(output) + if self.type == 'TEXT' and isinstance(ret, unicode): + ret = ret.encode(charset, 'xmlcharrefreplace') + return ret class SubmitButton(InputObj): @@ -486,6 +493,7 @@ class TextArea: self.readonly = readonly def Format(self, indent=0): + charset = get_translation().charset() or 'us-ascii' output = '<TEXTAREA NAME=%s' % self.name if self.rows: output += ' ROWS=%s' % self.rows @@ -496,6 +504,8 @@ class TextArea: if self.readonly: output += ' READONLY' output += '>%s</TEXTAREA>' % self.text + if isinstance(output, unicode): + output = output.encode(charset, 'xmlcharrefreplace') return output class FileUpload(InputObj): @@ -540,7 +550,9 @@ class WidgetArray: self.button_names, self.values): ischecked = (self.ischecked(i)) - item = self.Widget(self.name, value, ischecked).Format() + name + item = ('<label>' + + self.Widget(self.name, value, ischecked).Format() + + name + '</label>') items.append(item) if not self.horizontal: t.AddRow(items) |