2016-12-03 106 views
1

在應用Plone security patch 20161129之後,我們的PloneFormGen表單不再適用,因爲它包含元音變音(ä,ö,ß或€)。我們使用PloneFormGen 1.7.20,它是Plone 4.3.9的推薦版本。這裏的堆棧跟蹤:PloneFormGen在Plone安全補丁後的UnicodeDecodeError 20161129

Module zope.tales.tales, line 696, in evaluate 
    - URL: file:/var/plone/buildout-cache/eggs/Products.PloneFormGen-1.7.20-py2.7.egg/Products/PloneFormGen/skins/PloneFormGen/widget_fieldset_start.pt 
    - Line 25, Column 10 
    - Expression: <PythonExpr widget.Description(here)> 
    - Names: 
     {'container': <PloneSite at /mysite>, 
     'context': <FormFolder at /mysite/mitglied-werden>, 
     'desitelt': <object object at 0x7fe244f734b0>, 
     'here': <FormFolder at /mysite/mitglied-werden>, 
     'loop': {u'field': <Products.PageTemplates.Expressions.PathIterator object at 0x16fe5350>}, 
     'nothing': None, 
     'options': {'args':(), 
        'state': <Products.CMFFormController.ControllerState.ControllerState object at 0x7fe22c676610>}, 
     'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x1d61fc00>, 
     'request': <HTTPRequest, URL=https://www.example.org/mitglied-werden/fg_base_view_p3>, 
     'root': <Application at >, 
     'template': <FSControllerPageTemplate at /mysite/fg_base_view_p3 used for /mysite/mitglied-werden>, 
     'traverse_subpath': [], 
     'user': <PloneUser 'siteb390'>} 
    Module Products.PageTemplates.ZRPythonExpr, line 48, in __call__ 
    - __traceback_info__: widget.Description(here) 
    Module PythonExpr, line 1, in <expression> 
    Module Products.PloneFormGen.content.field_utils, line 27, in wDescription 
    Module zope.i18n, line 107, in translate 
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 20: ordinal not in range(128) 

刪除變音後它再次工作,但現在形式看起來有點不專業。

爲了這個錯誤,我在網上搜索了一個小時之後,我不知道哪個擴展會導致這個問題(PloneFormGen?)導致這個問題,以及如何解決這個問題: - 甚至不知道哪個方向看得更遠。 ..

+1

在https://github.com/smcmahon/Products.PloneFormGen/issues提交錯誤報告。確保你包含了你使用非ASCII字符的完整描述。 – SteveM

+1

看着1.7.20的更新日誌,我的直覺認爲它看起來像處理https://github.com/smcmahon/Products.PloneFormGen/issues/178中的錯誤,可能與安全補丁無關。 (不是說「安全補丁在unicode數據中斷」將是新的和令人驚訝的。)另外,我無法使用1.7.19和安裝的修復程序進行復制。 –

回答

3

從1.7.20開始,所有PFG描述字段都通過翻譯機制推送。 (請不要問我爲什麼要用用戶提供的字段來做這些事情,因爲說明字段首先不是語言不敏感的。)這會對您可以在說明中使用什麼字母施加額外的限制,就像您找到的那樣。

並不是說這是一個bug修正,但在我快審,修改buildout-cache/eggs/Products.PloneFormGen-1.7.20-py2.7.egg/Products/PloneFormGen/content/field_utils.py線27

 if value: 
     value = translate(value, context=instance.REQUEST) 
     return cgi.escape(value) 

if value: 
     value = translate(value.decode('utf-8'), context=instance.REQUEST) 
     return cgi.escape(value) 

使問題消失。

+0

現在似乎已經修復:https://github.com/smcmahon/Products.PloneFormGen/issues/182 – nachtigall

+4

菲利普提出了這個,我合併的拉請求。在1.7.21和1.8.3中修正。 – maurits

+1

感謝修復,菲利普和釋放,Maurits! – SteveM