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
138
Merge Requests
138
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
8c562ebb
Commit
8c562ebb
authored
Nov 11, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix TextDocument.getData with empty text content
parent
d6ce75af
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
bt5/erp5_web/TestTemplateItem/portal_components/test.erp5.testERP5Web.py
...stTemplateItem/portal_components/test.erp5.testERP5Web.py
+11
-0
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.TextDocument.py
...plateItem/portal_components/document.erp5.TextDocument.py
+4
-2
No files found.
bt5/erp5_web/TestTemplateItem/portal_components/test.erp5.testERP5Web.py
View file @
8c562ebb
...
...
@@ -252,6 +252,7 @@ class TestERP5Web(ERP5TypeTestCase):
page
.
edit
(
text_content
=
'<b>OK</b>'
)
self
.
assertEqual
(
'text/html'
,
page
.
getContentType
())
self
.
assertEqual
(
'<b>OK</b>'
,
page
.
getTextContent
())
self
.
assertEqual
(
b'<b>OK</b>'
,
page
.
getData
())
def
test_WebPageAsTextUTF8
(
self
):
"""Check if Web Page's asText() returns utf-8 string correctly
...
...
@@ -270,6 +271,16 @@ class TestERP5Web(ERP5TypeTestCase):
self
.
tic
()
self
.
assertEqual
(
'Hé!'
,
page
.
asText
().
strip
())
def
test_WebPageAsTextEmpty
(
self
):
page
=
self
.
web_page_module
.
newContent
(
portal_type
=
'Web Page'
)
self
.
tic
()
self
.
assertIsNone
(
page
.
getTextContent
())
self
.
assertIsNone
(
page
.
getData
())
default
=
[]
self
.
assertIs
(
page
.
getData
(
default
),
default
)
self
.
assertEqual
(
page
.
asText
(),
''
)
self
.
assertEqual
(
page
.
getSearchableText
(),
''
)
def
test_WebPageAsTextWrap
(
self
):
"""Check if Web Page's asText() is wrapped by certain column width.
"""
...
...
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.TextDocument.py
View file @
8c562ebb
...
...
@@ -417,7 +417,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, TextContent
return
self
.
_setContentType
(
value
)
def
getData
(
self
,
default
=
_MARKER
):
# type: () -> bytes | PData
# type: (
bytes
) -> bytes | PData
"""getData must returns original content but TextDocument accepts
data or text_content to store original content.
Fallback on text_content property if data is not defined
...
...
@@ -427,7 +427,9 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, TextContent
data
=
self
.
_baseGetTextContent
()
else
:
data
=
self
.
_baseGetTextContent
(
default
)
return
str2bytes
(
data
)
if
data
is
default
:
return
default
return
str2bytes
(
data
)
if
data
is
not
None
else
None
else
:
if
default
is
_MARKER
:
return
File
.
getData
(
self
)
...
...
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