Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
141
Merge Requests
141
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
66129a6e
Commit
66129a6e
authored
Jul 29, 2023
by
Emmy Vouriot
Committed by
Arnaud Fontaine
Jul 11, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
str to bytes WIP
parent
720719dd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
7 deletions
+13
-7
bt5/erp5_dms/DocumentTemplateItem/portal_components/document.erp5.PDFDocument.py
...mplateItem/portal_components/document.erp5.PDFDocument.py
+4
-4
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.EmailDocument.py
...lateItem/portal_components/document.erp5.EmailDocument.py
+6
-2
product/ERP5/bootstrap/erp5_core/MixinTemplateItem/portal_components/mixin.erp5.MailMessageMixin.py
...lateItem/portal_components/mixin.erp5.MailMessageMixin.py
+3
-1
No files found.
bt5/erp5_dms/DocumentTemplateItem/portal_components/document.erp5.PDFDocument.py
View file @
66129a6e
...
...
@@ -32,7 +32,7 @@ import zope.interface
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type
import
Permissions
,
PropertySheet
from
Products.ERP5Type.Utils
import
bytes2str
from
Products.ERP5Type.Utils
import
bytes2str
,
str2bytes
from
erp5.component.interface.IWatermarkable
import
IWatermarkable
from
erp5.component.document.Image
import
Image
from
erp5.component.document.Document
import
ConversionError
...
...
@@ -291,10 +291,10 @@ class PDFDocument(Image):
finally
:
tmp
.
close
()
# Quick hack to remove bg color - XXX
h
=
command_result
.
replace
(
'<BODY bgcolor="#A0A0A0"'
,
'<BODY '
)
h
=
command_result
.
replace
(
b'<BODY bgcolor="#A0A0A0"'
,
b
'<BODY '
)
# Make links relative
h
=
h
.
replace
(
'href="%s.html'
%
tmp
.
name
.
split
(
os
.
sep
)[
-
1
]
,
'href="asEntireHTML'
)
h
=
h
.
replace
(
str2bytes
(
'href="%s.html'
%
tmp
.
name
.
split
(
os
.
sep
)[
-
1
])
,
b
'href="asEntireHTML'
)
return
h
security
.
declarePrivate
(
'_convertToDJVU'
)
...
...
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.EmailDocument.py
View file @
66129a6e
...
...
@@ -28,6 +28,7 @@
##############################################################################
import
re
import
six
from
DateTime
import
DateTime
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type.Accessor.Constant
import
PropertyGetter
as
ConstantGetter
...
...
@@ -47,7 +48,10 @@ except ImportError:
not installed yet.
"""
from
email
import
message_from_string
if
six
.
PY2
:
from
email
import
message_from_string
as
message_from_x
else
:
from
email
import
message_from_bytes
as
message_from_x
from
email.utils
import
parsedate_tz
,
mktime_tz
DEFAULT_TEXT_FORMAT
=
'text/html'
...
...
@@ -170,7 +174,7 @@ class EmailDocument(TextDocument, MailMessageMixin):
content_type
=
self
.
getContentType
(),
embedded_file_list
=
self
.
getAggregateValueList
(
portal_type
=
document_type_list
),
)
result
=
message_from_
string
(
data
)
result
=
message_from_
x
(
data
)
self
.
_v_message
=
result
return
result
...
...
product/ERP5/bootstrap/erp5_core/MixinTemplateItem/portal_components/mixin.erp5.MailMessageMixin.py
View file @
66129a6e
...
...
@@ -35,6 +35,7 @@ from zLOG import LOG, INFO
from
email.header
import
decode_header
,
HeaderParseError
import
re
import
six
filename_regexp
=
'name="([^"]*)"'
...
...
@@ -43,7 +44,8 @@ def testCharsetAndConvert(text_content, content_type, encoding):
if
encoding
is
not
None
:
text_content
=
text_content
.
decode
(
encoding
).
encode
(
'utf-8'
)
else
:
text_content
=
text_content
.
decode
().
encode
(
'utf-8'
)
if
six
.
PY2
:
text_content
=
text_content
.
decode
().
encode
(
'utf-8'
)
except
(
UnicodeDecodeError
,
LookupError
):
encoding
=
guessEncodingFromText
(
text_content
,
content_type
)
if
encoding
is
not
None
:
...
...
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