|
|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
import sys |
|
|
|
import os |
|
|
|
import thunderbird |
|
|
|
import re |
|
|
|
from subprocess import Popen, PIPE |
|
|
@ -101,8 +102,27 @@ def pubkey_iterator(): |
|
|
|
class Rules: |
|
|
|
def __init__(self): |
|
|
|
try: |
|
|
|
self.et = ET.parse(os.path.join(profile_path(thunderbird_base), 'pgprules.xml')) |
|
|
|
self.et = ET.parse(os.path.join(thunderbird.profile_path(thunderbird_base), 'pgprules.xml')) |
|
|
|
self.rules = self.et.getroot() |
|
|
|
except: |
|
|
|
self.et = None |
|
|
|
self.rules = None |
|
|
|
|
|
|
|
def test_address(self, email): |
|
|
|
if self.rules is None: |
|
|
|
return True |
|
|
|
|
|
|
|
result = True |
|
|
|
for rule in self.rules: |
|
|
|
if rule.attrib['email'][0] == '{' and rule.attrib['email'][-1] == '}': |
|
|
|
if email == rule.attrib['email'][1:-1]: |
|
|
|
result = rule.attrib['encrypt'] != '0' |
|
|
|
if rule.attrib['keyId'] == '.': |
|
|
|
break |
|
|
|
elif len(rule.attrib['keyId']) > 2: |
|
|
|
return rule.attrib['keyId'][2:] |
|
|
|
|
|
|
|
return result |
|
|
|
|
|
|
|
rules = Rules() |
|
|
|
|