diff options
| author | Barry Warsaw | 2009-03-03 00:31:03 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2009-03-03 00:31:03 -0500 |
| commit | f3ee1ed7d9198d79f7feaf6fb3bb5b6e5ae4bd38 (patch) | |
| tree | 2c233acf23575b15cbaadfb67298c96b751651ce /src/mailman/pipeline/docs | |
| parent | b6ed8a7c98ea02af9014793f3b508c601da6ea75 (diff) | |
| download | mailman-f3ee1ed7d9198d79f7feaf6fb3bb5b6e5ae4bd38.tar.gz mailman-f3ee1ed7d9198d79f7feaf6fb3bb5b6e5ae4bd38.tar.zst mailman-f3ee1ed7d9198d79f7feaf6fb3bb5b6e5ae4bd38.zip | |
Diffstat (limited to 'src/mailman/pipeline/docs')
| -rw-r--r-- | src/mailman/pipeline/docs/filtering.txt | 75 |
1 files changed, 39 insertions, 36 deletions
diff --git a/src/mailman/pipeline/docs/filtering.txt b/src/mailman/pipeline/docs/filtering.txt index 70ca3098d..f895220f0 100644 --- a/src/mailman/pipeline/docs/filtering.txt +++ b/src/mailman/pipeline/docs/filtering.txt @@ -3,12 +3,9 @@ Content filtering Mailman can filter the content of messages posted to a mailing list by stripping MIME subparts, and possibly reorganizing the MIME structure of a -message. It does this with the MimeDel handler module, although other -handlers can potentially do other kinds of finer level content filtering. +message. - >>> from mailman.pipeline.mime_delete import process - >>> mlist = config.db.list_manager.create(u'_xtest@example.com') - >>> mlist.preferred_language = u'en' + >>> mlist = create_list(u'test@example.com') Several mailing list options control content filtering. First, the feature must be enabled, then there are two options that control which MIME types get @@ -17,8 +14,8 @@ text/html parts will get converted to plain text. Let's set up some defaults for these variables, then we'll explain them in more detail below. >>> mlist.filter_content = True - >>> mlist.filter_mime_types = [] - >>> mlist.pass_mime_types = [] + >>> mlist.filter_types = [] + >>> mlist.pass_types = [] >>> mlist.convert_html_to_plaintext = False @@ -29,9 +26,11 @@ A simple filtering setting will just search the content types of the messages parts, discarding all parts with a matching MIME type. If the message's outer content type matches the filter, the entire message will be discarded. - >>> mlist.filter_mime_types = ['image/jpeg'] - >>> # XXX Change this to an enum - >>> mlist.filter_action = 0 # Discard + >>> from mailman.interfaces.mime import FilterAction + + >>> mlist.filter_types = [u'image/jpeg'] + >>> mlist.filter_action = FilterAction.discard + >>> msg = message_from_string("""\ ... From: aperson@example.com ... Content-Type: image/jpeg @@ -39,6 +38,8 @@ content type matches the filter, the entire message will be discarded. ... ... xxxxx ... """) + + >>> process = config.handlers['mime-delete'].process >>> process(mlist, msg, {}) Traceback (most recent call last): ... @@ -85,20 +86,21 @@ just that subpart will be stripped. ... From: aperson@example.com ... Content-Type: multipart/mixed; boundary=BOUNDARY ... MIME-Version: 1.0 - ... + ... ... --BOUNDARY ... Content-Type: image/jpeg ... MIME-Version: 1.0 - ... + ... ... xxx - ... + ... ... --BOUNDARY ... Content-Type: image/gif ... MIME-Version: 1.0 - ... + ... ... yyy ... --BOUNDARY-- ... """) + >>> process(mlist, msg, {}) >>> print msg.as_string() From: aperson@example.com @@ -136,24 +138,24 @@ subpart. ... From: aperson@example.com ... Content-Type: multipart/mixed; boundary=BOUNDARY ... MIME-Version: 1.0 - ... + ... ... --BOUNDARY ... Content-Type: multipart/alternative; boundary=BOUND2 ... MIME-Version: 1.0 - ... + ... ... --BOUND2 ... Content-Type: image/jpeg ... MIME-Version: 1.0 - ... + ... ... xxx - ... + ... ... --BOUND2 ... Content-Type: image/gif ... MIME-Version: 1.0 - ... + ... ... yyy ... --BOUND2-- - ... + ... ... --BOUNDARY-- ... """) >>> process(mlist, msg, {}) @@ -176,21 +178,22 @@ part with just one subpart, the entire message is converted to the left over part's content type. In other words, the left over inner part is promoted to being the outer part. - >>> mlist.filter_mime_types.append('text/html') + >>> mlist.filter_types = [u'image/jpeg', u'text/html'] >>> msg = message_from_string("""\ ... From: aperson@example.com ... Content-Type: multipart/alternative; boundary=AAA - ... + ... ... --AAA ... Content-Type: text/html - ... + ... ... <b>This is some html</b> ... --AAA ... Content-Type: text/plain - ... + ... ... This is plain text ... --AAA-- ... """) + >>> process(mlist, msg, {}) >>> print msg.as_string() From: aperson@example.com @@ -201,7 +204,7 @@ being the outer part. Clean up. - >>> ignore = mlist.filter_mime_types.pop() + >>> mlist.filter_types = [u'image/jpeg'] Conversion to plain text @@ -245,7 +248,7 @@ name of the file containing the message payload to filter. ... From: aperson@example.com ... Content-Type: text/html ... MIME-Version: 1.0 - ... + ... ... <html><head></head> ... <body></body></html> ... """) @@ -272,39 +275,39 @@ the entire inner multipart/mixed is discarded. >>> msg = message_from_string("""\ ... From: aperson@example.com ... Content-Type: multipart/mixed; boundary=AAA - ... + ... ... --AAA ... Content-Type: multipart/mixed; boundary=BBB - ... + ... ... --BBB ... Content-Type: image/jpeg - ... + ... ... xxx ... --BBB ... Content-Type: image/jpeg - ... + ... ... yyy ... --BBB--- ... --AAA ... Content-Type: multipart/alternative; boundary=CCC - ... + ... ... --CCC ... Content-Type: text/html - ... + ... ... <h2>This is a header</h2> - ... + ... ... --CCC ... Content-Type: text/plain - ... + ... ... A different message ... --CCC-- ... --AAA ... Content-Type: image/gif - ... + ... ... zzz ... --AAA ... Content-Type: image/gif - ... + ... ... aaa ... --AAA-- ... """) |
