diff options
Diffstat (limited to 'Mailman/htmlformat.py')
-rwxr-xr-x[-rw-r--r--] | Mailman/htmlformat.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/Mailman/htmlformat.py b/Mailman/htmlformat.py index 5d70ad28..419fa296 100644..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-2015 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 @@ -300,7 +300,7 @@ class Document(Container): def Format(self, indent=0, **kws): charset = 'us-ascii' - if self.language: + if self.language and Utils.IsLanguage(self.language): charset = Utils.GetCharSet(self.language) output = ['Content-Type: text/html; charset=%s\n' % charset] if not self.suppress_head: @@ -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 @@ -441,6 +443,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 +451,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, 'replace') + return ret class SubmitButton(InputObj): @@ -486,6 +492,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 +503,8 @@ class TextArea: if self.readonly: output += ' READONLY' output += '>%s</TEXTAREA>' % self.text + if isinstance(output, unicode): + output = output.encode(charset, 'replace') return output class FileUpload(InputObj): @@ -540,7 +549,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) |