Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Anti-censorship
BridgeDB
Commits
f8907b32
Unverified
Commit
f8907b32
authored
Jul 22, 2014
by
Isis Lovecruft
Browse files
Merge branch 'fix/12627-hotfixes' into develop
parents
91142d6c
42241075
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/bridgedb/email/autoresponder.py
View file @
f8907b32
...
...
@@ -75,7 +75,7 @@ def createResponseBody(lines, context, client, lang='en'):
%
str
(
client
))
# Otherwise they must have requested bridges:
interval
=
context
.
schedule
.
getI
nterval
(
time
.
time
())
interval
=
context
.
schedule
.
i
nterval
Start
(
time
.
time
())
bridges
=
context
.
distributor
.
getBridgesForEmail
(
str
(
client
),
interval
,
...
...
@@ -136,9 +136,9 @@ def generateResponse(fromAddress, client, body, subject=None,
"""
response
=
EmailResponse
(
gpgContext
)
response
.
to
=
client
response
.
writeHeaders
(
fromAddress
,
str
(
client
),
subject
,
response
.
writeHeaders
(
fromAddress
.
encode
(
'utf-8'
)
,
str
(
client
),
subject
,
inReplyTo
=
messageID
)
response
.
writeBody
(
body
)
response
.
writeBody
(
body
.
encode
(
'utf-8'
)
)
# Only log the email text (including all headers) if SAFE_LOGGING is
# disabled:
...
...
@@ -221,9 +221,9 @@ class EmailResponse(object):
self
.
__class__
.
__name__
))
try
:
if
size
is
not
None
:
contents
=
self
.
mailfile
.
read
(
int
(
size
))
contents
=
self
.
mailfile
.
read
(
int
(
size
))
.
encode
(
'utf-8'
)
else
:
contents
=
self
.
mailfile
.
read
()
contents
=
self
.
mailfile
.
read
()
.
encode
(
'utf-8'
)
except
Exception
as
error
:
# pragma: no cover
logging
.
exception
(
error
)
...
...
@@ -306,24 +306,25 @@ class EmailResponse(object):
self
.
write
(
"From: %s"
%
fromAddress
)
self
.
write
(
"To: %s"
%
toAddress
)
if
includeMessageID
:
self
.
write
(
"Message-ID: %s"
%
smtp
.
messageid
())
self
.
write
(
"Message-ID: %s"
%
smtp
.
messageid
()
.
encode
(
'utf-8'
)
)
if
inReplyTo
:
self
.
write
(
"In-Reply-To: %s"
%
inReplyTo
)
self
.
write
(
"Content-Type: %s"
%
contentType
)
self
.
write
(
"Date: %s"
%
smtp
.
rfc822date
())
self
.
write
(
"In-Reply-To: %s"
%
inReplyTo
.
encode
(
'utf-8'
)
)
self
.
write
(
"Content-Type: %s"
%
contentType
.
encode
(
'utf-8'
)
)
self
.
write
(
"Date: %s"
%
smtp
.
rfc822date
()
.
encode
(
'utf-8'
)
)
if
not
subject
:
subject
=
'[no subject]'
if
not
subject
.
lower
().
startswith
(
're'
):
subject
=
"Re: "
+
subject
self
.
write
(
"Subject: %s"
%
subject
)
self
.
write
(
"Subject: %s"
%
subject
.
encode
(
'utf-8'
)
)
if
kwargs
:
for
headerName
,
headerValue
in
kwargs
.
items
():
headerName
=
headerName
.
capitalize
()
headerName
=
headerName
.
replace
(
' '
,
'-'
)
headerName
=
headerName
.
replace
(
'_'
,
'-'
)
self
.
write
(
"%s: %s"
%
(
headerName
,
headerValue
))
header
=
"%s: %s"
%
(
headerName
,
headerValue
)
self
.
write
(
header
.
encode
(
'utf-8'
))
# The first blank line designates that the headers have ended:
self
.
write
(
self
.
delimiter
)
...
...
@@ -630,12 +631,12 @@ class SMTPAutoresponder(smtp.SMTPClient):
# The canonical domains from the SMTP ``MAIL FROM:`` and the email
# ``From:`` header should match:
if
self
.
incoming
.
canonicalFromSMTP
!=
self
.
incoming
.
canonicalFromEmail
:
logging
.
error
(
"SMTP/Email canonical domain mismatch!"
)
logging
.
debug
(
"Canonical domain mismatch: %s != %s"
%
(
self
.
incoming
.
canonicalFromSMTP
,
self
.
incoming
.
canonicalFromEmail
))
return
False
#
if self.incoming.canonicalFromSMTP != self.incoming.canonicalFromEmail:
#
logging.error("SMTP/Email canonical domain mismatch!")
#
logging.debug("Canonical domain mismatch: %s != %s"
#
% (self.incoming.canonicalFromSMTP,
#
self.incoming.canonicalFromEmail))
#
return False
self
.
incoming
.
domainRules
=
self
.
incoming
.
context
.
domainRules
.
get
(
self
.
incoming
.
canonicalFromEmail
,
list
())
...
...
lib/bridgedb/email/server.py
View file @
f8907b32
...
...
@@ -176,7 +176,7 @@ class SMTPMessage(object):
self
.
lines
.
append
(
line
)
if
not
safelog
.
safe_logging
:
try
:
logging
.
debug
(
"> %s"
,
line
.
rstrip
(
"
\r\n
"
))
logging
.
debug
(
"> %s"
,
line
.
rstrip
(
"
\r\n
"
)
.
encode
(
'utf-8'
)
)
except
UnicodeError
:
# pragma: no cover
pass
except
Exception
as
error
:
# pragma: no cover
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment