Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pymilter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
misc
pymilter
Commits
4251fbc1
Commit
4251fbc1
authored
5 years ago
by
Stuart D. Gathman
Browse files
Options
Downloads
Patches
Plain Diff
Work in python2 and python3
parent
4749f0ff
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Milter/__init__.py
+5
-1
5 additions, 1 deletion
Milter/__init__.py
Milter/testctx.py
+3
-2
3 additions, 2 deletions
Milter/testctx.py
miltermodule.c
+5
-1
5 additions, 1 deletion
miltermodule.c
with
13 additions
and
4 deletions
Milter/__init__.py
+
5
−
1
View file @
4251fbc1
...
...
@@ -14,6 +14,7 @@ __version__ = '1.0.4'
import
os
import
re
import
milter
import
sys
try
:
import
thread
except
:
...
...
@@ -773,7 +774,10 @@ def runmilter(name,socketname,timeout = 0,rmsock=True):
# dictfromlist to make parsing the ESMTP args convenient.
milter
.
set_envfrom_callback
(
lambda
ctx
,
*
str
:
ctx
.
getpriv
().
envfrom
(
*
str
))
milter
.
set_envrcpt_callback
(
lambda
ctx
,
*
str
:
ctx
.
getpriv
().
envrcpt
(
*
str
))
milter
.
set_header_callback
(
lambda
ctx
,
fld
,
val
:
ctx
.
getpriv
().
header
(
fld
,
val
))
if
sys
.
version
<
'
3.0.0
'
:
milter
.
set_header_callback
(
lambda
ctx
,
f
,
v
:
ctx
.
getpriv
().
header
(
f
,
v
))
else
:
milter
.
set_header_callback
(
header_callback
)
milter
.
set_eoh_callback
(
lambda
ctx
:
ctx
.
getpriv
().
eoh
())
milter
.
set_body_callback
(
lambda
ctx
,
chunk
:
ctx
.
getpriv
().
body
(
chunk
))
milter
.
set_eom_callback
(
lambda
ctx
:
ctx
.
getpriv
().
eom
())
...
...
This diff is collapsed.
Click to expand it.
Milter/testctx.py
+
3
−
2
View file @
4251fbc1
...
...
@@ -6,6 +6,7 @@
from
__future__
import
print_function
from
socket
import
AF_INET
,
AF_INET6
from
sys
import
version
as
VERSION
import
time
import
mime
try
:
...
...
@@ -14,8 +15,6 @@ except:
from
StringIO
import
StringIO
as
BytesIO
import
Milter
from
Milter
import
utils
import
mime
import
email
## Milter context for unit testing %milter applications.
# A substitute for milter.milterContext that can be passed to
...
...
@@ -220,6 +219,8 @@ class TestCtx(object):
return
rc
def
_header
(
self
,
fld
,
val
):
if
VERSION
<
'
3.0.0
'
:
return
self
.
_priv
.
header
(
fld
,
val
)
# email.message_from_binary_file uses surrogateescape to
# preserve original bytes in unicode string for decoding errors.
# convert str or Header back to original bytes
...
...
This diff is collapsed.
Click to expand it.
miltermodule.c
+
5
−
1
View file @
4251fbc1
...
...
@@ -674,7 +674,11 @@ milter_wrap_header(SMFICTX *ctx, char *headerf, char *headerv) {
if
(
header_callback
==
NULL
)
return
SMFIS_CONTINUE
;
c
=
_get_context
(
ctx
);
if
(
!
c
)
return
SMFIS_TEMPFAIL
;
arglist
=
Py_BuildValue
(
"(Oyy)"
,
c
,
headerf
,
headerv
);
#if PY_MAJOR_VERSION >= 3
arglist
=
Py_BuildValue
(
"(Osy)"
,
c
,
headerf
,
headerv
);
#else
arglist
=
Py_BuildValue
(
"(Oss)"
,
c
,
headerf
,
headerv
);
#endif
return
_generic_wrapper
(
c
,
header_callback
,
arglist
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment