changeset 1289:01d6d28d5039

mailimport: treating empty subjects better, normalize pagename
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 15 Aug 2006 17:55:12 +0200
parents 7a7c7da7af90
children 655978c9f6c3
files MoinMoin/mail/mailimport.py
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/mail/mailimport.py	Tue Aug 15 17:31:41 2006 +0200
+++ b/MoinMoin/mail/mailimport.py	Tue Aug 15 17:55:12 2006 +0200
@@ -5,9 +5,7 @@
     and feed the mail into stdin.
 
     TODO:
-     * sanitize pagename in the same way as when we get it from url
      * add from/to/subj infos when attaching to main page (without +)
-     * check + usage when not using subpages
 
     @copyright: 2006 by MoinMoin:AlexanderSchremmer,
                 2006 by MoinMoin:ThomasWaldmann
@@ -126,10 +124,9 @@
             'from_addr': from_addr,
             'subject': subject, 'date': date}
 
-def get_pagename_content(msg, email_subpage_template, wiki_address):
+def get_pagename_content(request, msg, email_subpage_template, wiki_address):
     """ Generates pagename and content according to the specification
         that can be found on MoinMoin:FeatureRequests/WikiEmailintegration """
-
     generate_summary = False
     choose_html = True
 
@@ -152,6 +149,9 @@
         if pagename_tpl[-1] == pagename_tpl[0] == "'":
             pagename_tpl = pagename_tpl[1:-1]
 
+    if not msg['subject'].strip():
+        msg['subject'] = '(...)' # we need non-empty subject
+
     pagename_tpl = pagename_tpl.strip()
     if pagename_tpl.endswith("/"):
         pagename_tpl += email_subpage_template
@@ -169,6 +169,8 @@
         generate_summary = True
         pagename = pagename[1:].lstrip()
 
+    pagename = request.normalizePagename(pagename)
+
     if choose_html and msg['html']:
         content = "{{{#!html\n%s\n}}}" % msg['html'].replace("}}}", "} } }")
     else:
@@ -200,7 +202,7 @@
     if not request.user:
         raise ProcessingError("No suitable user found for mail address %r" % (msg['from_addr'][1], ))
 
-    d = get_pagename_content(msg, email_subpage_template, wiki_address)
+    d = get_pagename_content(request, msg, email_subpage_template, wiki_address)
     pagename = d['pagename']
     generate_summary = d['generate_summary']
 
@@ -272,7 +274,7 @@
         from_col = email_to_markup(request, msg['from_addr'])
         to_col = ' '.join([email_to_markup(request, (realname, mailaddr))
                            for realname, mailaddr in msg['target_addrs'] if mailaddr != wiki_address])
-        subj_col = '["%s" %s]' % (pagename, msg['subject'] or '(...)')
+        subj_col = '["%s" %s]' % (pagename, msg['subject'])
         date_col = msg['date']
         attach_col = " ".join(attachment_links)
         new_line = u'|| %s || %s || %s || [[DateTime(%s)]] || %s ||' % (from_col, to_col, subj_col, date_col, attach_col)