From 28ce749df7bf5607e96f0e011a50a863473da06f Mon Sep 17 00:00:00 2001 From: bwarsaw Date: Fri, 26 Oct 2001 22:29:54 +0000 Subject: Tokio Kikuchi says: Some time ago, someone complained about the pipermail not representing proper charset in the Content-Type header. Here is a patch for the latest CVS (2.1a). With some changes by Barry, specifically to get the charset parameter out of the Content-Type: header using email.Message's interface instead of regexp searching. Please double check this for me! --- Mailman/Archiver/HyperArch.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Mailman/Archiver/HyperArch.py b/Mailman/Archiver/HyperArch.py index ed4183d46..87b2b3f1b 100644 --- a/Mailman/Archiver/HyperArch.py +++ b/Mailman/Archiver/HyperArch.py @@ -105,10 +105,6 @@ urlpat = re.compile(r'(\w+://[^>)\s]+)') # URLs in text # Blank lines blankpat = re.compile(r'^\s*$') -# content-type charset -rx_charset = re.compile('charset="(\w+)"') - -# # Starting directive htmlpat = re.compile(r'^\s*\s*$', re.IGNORECASE) # Ending directive @@ -142,7 +138,7 @@ class Article(pipermail.Article): _last_article_time = time.time() # for compatibility with old archives loaded via pickle - charset = mm_cfg.DEFAULT_CHARSET + x, charset = mm_cfg.LC_DESCRIPTIONS[mm_cfg.DEFAULT_SERVER_LANGUAGE] cenc = None decoded = {} @@ -172,9 +168,9 @@ class Article(pipermail.Article): self.ctype = ctype.lower() self.cenc = cenc.lower() self.decoded = {} - mo = rx_charset.search(self.ctype) - if mo: - self.check_header_charsets(mo.group(1).lower()) + charset = message.get_param('charset') + if charset: + self.check_header_charsets(charset) else: self.check_header_charsets() if self.charset and self.charset in mm_cfg.VERBATIM_ENCODING: @@ -196,6 +192,7 @@ class Article(pipermail.Article): header, then an arbitrary charset is chosen. Only those values that match the chosen charset are decoded. """ + self.charset = msg_charset author, a_charset = self.decode_charset(self.author) subject, s_charset = self.decode_charset(self.subject) if author is not None or subject is not None: @@ -529,7 +526,9 @@ class HyperArchive(pipermail.T): self._unlocklist = unlock self._lock_file = None self._charsets = {} - self.charset = None + x, self.charset = mm_cfg.LC_DESCRIPTIONS.get( + maillist.preferred_language, + mm_cfg.LC_DESCRIPTIONS[mm_cfg.DEFAULT_SERVER_LANGUAGE]) if hasattr(self.maillist,'archive_volume_frequency'): if self.maillist.archive_volume_frequency == 0: -- cgit v1.3.1