Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Kirill Smelkov
Zope
Commits
a281c8bb
Commit
a281c8bb
authored
Jan 11, 2007
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed content-type restrictions (text/html, text/xml only)
parent
0d930600
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
18 deletions
+20
-18
lib/python/Products/PageTemplates/ZopePageTemplate.py
lib/python/Products/PageTemplates/ZopePageTemplate.py
+8
-5
lib/python/Products/PageTemplates/utils.py
lib/python/Products/PageTemplates/utils.py
+12
-13
No files found.
lib/python/Products/PageTemplates/ZopePageTemplate.py
View file @
a281c8bb
...
...
@@ -126,7 +126,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
encoding
=
None
output_encoding
=
None
if
content_type
==
'text/xml'
:
if
content_type
in
(
'text/xml'
,)
:
if
is_unicode
:
encoding
=
None
...
...
@@ -136,7 +136,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
output_encoding
=
'utf-8'
elif
content_type
==
'text/html'
:
elif
content_type
in
(
'text/html'
,)
:
charset
=
charsetFromMetaEquiv
(
text
)
...
...
@@ -156,7 +156,10 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
output_encoding
=
'iso-8859-15'
else
:
raise
ValueError
(
'Unsupported content-type %s'
%
content_type
)
utext
,
encoding
=
convertToUnicode
(
text
,
content_type
,
preferred_encodings
)
output_encoding
=
encoding
# for content updated through WebDAV, FTP
if
not
keep_output_encoding
:
...
...
@@ -228,8 +231,8 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
text
=
file
.
read
()
content_type
=
guess_type
(
filename
,
text
)
if
not
content_type
in
(
'text/html'
,
'text/xml'
):
raise
ValueError
(
'Unsupported mimetype: %s'
%
content_type
)
#
if not content_type in ('text/html', 'text/xml'):
#
raise ValueError('Unsupported mimetype: %s' % content_type)
self
.
pt_edit
(
text
,
content_type
)
return
self
.
pt_editForm
(
manage_tabs_message
=
'Saved changes'
)
...
...
lib/python/Products/PageTemplates/utils.py
View file @
a281c8bb
...
...
@@ -70,20 +70,19 @@ def convertToUnicode(source, content_type, preferred_encodings):
elif content_type.startswith('
text
/
html
'):
encoding = charsetFromMetaEquiv(source)
if encoding:
return unicode(source, encoding), encoding
# Try to detect the encoding by converting it unicode without raising
# exceptions. There are some smarter Python-based sniffer methods
# available however we have to check their licenses first before
# including them into the Zope 2 core
# Try to detect the encoding by converting it unicode without raising
# exceptions. There are some smarter Python-based sniffer methods
# available however we have to check their licenses first before
# including them into the Zope 2 core
if not encoding:
for enc in preferred_encodings:
try:
return unicode(source, enc), enc
except UnicodeDecodeError:
continue
for enc in preferred_encodings:
try:
return unicode(source, enc), enc
except UnicodeDecodeError:
continue
raise TypeError('
Could
not
auto
-
detect
encoding
')
return unicode(source), None
else:
raise ValueError('
Unsupported
content
-
type
:
%
s
' % content_type)
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