Skip to content

Parse Error with tags with newline #219

Closed

Description

@thet

I encountered a parse error with tags names, where a newline is in it. It's the following template from collective.easyform:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:tal="http://xml.zope.org/namespaces/tal">
  <head><title></title></head>
  <body>
    <p tal:content="body_pre | nothing" />
    <dl>
        <tal:block repeat="field data | nothing">
            <dt tal:content="python:fields[field]" />
            <dd tal:content="structure python:data[field]" />
        </tal:block>
    </dl>
    <p tal:content="body_post | nothing" />
    <pre tal:content="body_footer | nothing" />
  </body>
</html>

https://github.com/collective/collective.easyform/blob/487556605f2d05f6d4079ffaf00d5474b96297ad/collective/easyform/default_schemata/mail_body_default.pt

This is the error:

  Module chameleon.parser, line 193, in parse
  Module chameleon.parser, line 238, in visit_end_tag
ParseError: Unexpected end tag.

 - String:     "</html>"
 - Filename:   mailer
 - Location:   (line 16: col 0)

I stepped into visit_end_tag and found out, that name has the value u'html\r' while node['name'] has u'html'.

The error persisted, event after removing the newline from the html starting tag and clearing the chameleon cache.

As I understand, the chameleon integration in Plone compactifies templates a bit. This might not be the case in how collective.easyform is using it.

The template is used as follows:

        template = ZopePageTemplate(self.__name__)
        template.write(bodyfield)
        template = template.__of__(context)
        body = template.pt_render(extra_context=extra)  # HERE THE ERROR IS THROWN

https://github.com/collective/collective.easyform/blob/487556605f2d05f6d4079ffaf00d5474b96297ad/collective/easyform/actions.py#L195

This is the complete traceback:

> /opt/bda/amkumma-LIVE/eggs/Chameleon-2.24-py2.7.egg/chameleon/parser.py(238)visit_end_tag()
-> raise ParseError("Unexpected end tag.", token)
(Pdb) c
2016-09-23 21:49:35 ERROR Zope.SiteErrorLog 1474660175.160.124260256347 http://localhost:20099/plone/altach/kontakt-formular/view
Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module plone.z3cform.layout, line 66, in __call__
  Module plone.z3cform.layout, line 50, in update
  Module collective.easyform.browser.view, line 256, in update
  Module plone.z3cform.fieldsets.extensible, line 59, in update
  Module plone.z3cform.patch, line 30, in GroupForm_update
  Module z3c.form.group, line 145, in update
  Module plone.app.z3cform.csrf, line 21, in execute
  Module z3c.form.action, line 98, in execute
  Module z3c.form.button, line 315, in __call__
  Module z3c.form.button, line 170, in __call__
  Module collective.easyform.browser.view, line 159, in handleSubmit
  Module collective.easyform.browser.view, line 122, in processActions
  Module collective.easyform.actions, line 466, in onSuccess
  Module collective.easyform.actions, line 402, in get_mail_text
  Module collective.easyform.actions, line 196, in get_mail_body
  Module Products.PageTemplates.ZopePageTemplate, line 306, in write
  Module zope.pagetemplate.pagetemplate, line 162, in write
  Module zope.pagetemplate.pagetemplate, line 212, in _cook
  Module five.pt.engine, line 132, in cook
  Module chameleon.zpt.template, line 166, in __init__
  Module chameleon.template, line 116, in __init__
  Module chameleon.template, line 209, in write
  Module chameleon.template, line 146, in cook
  Module chameleon.template, line 219, in _cook
  Module chameleon.template, line 250, in _make
  Module chameleon.zpt.template, line 206, in parse
  Module chameleon.zpt.program, line 164, in __init__
  Module chameleon.program, line 31, in __init__
  Module chameleon.parser, line 185, in __iter__
  Module chameleon.parser, line 193, in parse
  Module chameleon.parser, line 238, in visit_end_tag
ParseError: Unexpected end tag.

 - String:     "</html>"
 - Filename:   mailer
 - Location:   (line 16: col 0)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions