mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-14 00:26:21 +00:00
The 'API' is written but untested
This commit is contained in:
@@ -12,6 +12,7 @@ from dateutil import parser
|
||||
from django.conf import settings
|
||||
|
||||
from .consumer import Consumer
|
||||
from .models import Sender
|
||||
|
||||
|
||||
class MailFetcherError(Exception):
|
||||
@@ -28,10 +29,6 @@ class Message(object):
|
||||
and n attachments, and that we don't care about the message body.
|
||||
"""
|
||||
|
||||
# This regex is probably more restrictive than it needs to be, but it's
|
||||
# better safe than sorry.
|
||||
SAFE_SUBJECT_REGEX = re.compile(r"^[\w\- ,.']+$")
|
||||
|
||||
def _set_time(self, message):
|
||||
self.time = datetime.datetime.now()
|
||||
message_time = message.get("Date")
|
||||
@@ -58,7 +55,7 @@ class Message(object):
|
||||
|
||||
if self.subject is None:
|
||||
raise InvalidMessageError("Message does not have a subject")
|
||||
if not self.SAFE_SUBJECT_REGEX.match(self.subject):
|
||||
if not Sender.SAFE_REGEX.match(self.subject):
|
||||
raise InvalidMessageError("Message subject is unsafe")
|
||||
|
||||
print('Fetching email: "{}"'.format(self.subject))
|
||||
|
Reference in New Issue
Block a user