Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5_rtl_support
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
erp5_rtl_support
Commits
752482f5
Commit
752482f5
authored
Sep 15, 2011
by
Nicolas Delaby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test to check safe_html conversion of flawed attachment
parent
c73b4e5f
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
284 additions
and
0 deletions
+284
-0
product/ERP5/tests/testCRM.py
product/ERP5/tests/testCRM.py
+36
-0
product/ERP5/tests/test_data/broken_html.html
product/ERP5/tests/test_data/broken_html.html
+248
-0
No files found.
product/ERP5/tests/testCRM.py
View file @
752482f5
...
...
@@ -39,6 +39,10 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\
from
Products.ERP5OOo.tests.testIngestion
import
FILENAME_REGULAR_EXPRESSION
from
Products.ERP5OOo.tests.testIngestion
import
REFERENCE_REGULAR_EXPRESSION
from
Products.ERP5Type.tests.backportUnittest
import
expectedFailure
from
email.MIMEMultipart
import
MIMEMultipart
from
email.MIMEBase
import
MIMEBase
from
email.MIMEText
import
MIMEText
from
email
import
Encoders
def
makeFilePath
(
name
):
return
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'test_data'
,
'crm_emails'
,
name
)
...
...
@@ -784,6 +788,38 @@ class TestCRMMailIngestion(BaseTestCRM):
mixed_document
.
getTextContent
())
self
.
assertEquals
(
'text/plain'
,
mixed_document
.
getContentType
())
def
test_flawed_html_attachment
(
self
):
portal_type
=
'Mail Message'
event
=
self
.
portal
.
getDefaultModule
(
portal_type
).
newContent
(
portal_type
=
portal_type
)
# build message content with flwd attachment
plain_text_message
=
'You can read this'
html_filename
=
'broken_html.html'
file_path
=
'%s/test_data/%s'
%
(
__file__
.
rstrip
(
'c'
).
replace
(
__name__
+
'.py'
,
''
),
html_filename
,)
html_message
=
open
(
file_path
,
'r'
).
read
()
message
=
MIMEMultipart
(
'alternative'
)
message
.
attach
(
MIMEText
(
'text plain content'
,
_charset
=
'utf-8'
))
part
=
MIMEBase
(
'text'
,
'html'
)
part
.
set_payload
(
html_message
)
Encoders
.
encode_base64
(
part
)
part
.
add_header
(
'Content-Disposition'
,
'attachment'
,
filename
=
html_filename
)
part
.
add_header
(
'Content-ID'
,
'<%s>'
%
\
''
.
join
([
'%s'
%
ord
(
i
)
for
i
in
html_filename
]))
message
.
attach
(
part
)
event
.
setData
(
message
.
as_string
())
transaction
.
commit
()
self
.
tic
()
self
.
assertTrue
(
'html'
in
event
.
getTextContent
())
self
.
assertEquals
(
len
(
event
.
getAttachmentInformationList
()),
2
)
self
.
assertTrue
(
bool
(
event
.
getAttachmentData
(
1
)))
self
.
assertTrue
(
bool
(
event
.
getAttachmentData
(
2
)))
## TODO:
##
...
...
product/ERP5/tests/test_data/broken_html.html
0 → 100644
View file @
752482f5
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
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