Skip to content

Commit

Permalink
one more attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
gotcha committed May 16, 2023
1 parent c290ee5 commit dd75c79
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/collective/ckeditor/browser/ckeditorsettings.py
Expand Up @@ -11,7 +11,7 @@
from zope.schema import ASCIILine
from zope.schema import Bool
from zope.schema import Choice
from zope.schema import Bytes
from zope.schema import Text
from zope.schema import Tuple
from zope.schema import List

Expand Down Expand Up @@ -104,7 +104,7 @@ class ICKEditorBaseSchema(Interface):
),
required=False)

menuStyles = Bytes(
menuStyles = Text(
title=_(u"Menu styles"),
description=_(u"Build your own CKEditor menu styles Combo box. "
u"Take care with the javascript syntax. "
Expand Down
4 changes: 2 additions & 2 deletions src/collective/ckeditor/pytests/test_upgrade.py
Expand Up @@ -191,13 +191,13 @@ def test_upgrade_of_menuStyles(plone_instance):
selected = soup.select("#form-widgets-value")
assert len(selected) == 1
field = selected[0]
assert field.name == "input"
assert field.name == "textarea"
menuStyle = """
{ name : 'upgrade ascii Title' , element : 'h2', styles : { 'color' : '#888' } },
{ name : 'upgrade unicode Title éè' , element : 'h2', styles : { 'color' : '#888' } },
"""
for line in menuStyle.splitlines():
assert line.strip() in field.value
assert line.strip() in field.text


@pytest.mark.upgrade
Expand Down
6 changes: 4 additions & 2 deletions src/collective/ckeditor/upgrades.py
Expand Up @@ -334,21 +334,23 @@ def to_registry(context):
IS_PYTHON2 = sys.version_info[0] == 2
if IS_PYTHON2:
text_type = unicode
binary_type = str
string_none = "None"
else:
text_type = str
binary_type = bytes
string_none = b"None"


def safe_string(value):
if value is None:
return ''
return binary_type()
if isinstance(value, text_type):
result = value.encode('utf8')
else:
result = value
# workaround old settings screen that stored empty input as "None" string
if result == string_none:
return ''
return binary_type()
else:
return result

0 comments on commit dd75c79

Please sign in to comment.