Edgewall Software
Modify

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#13307 closed defect (fixed)

jinjachecker doesn't correctly parse multiline expressions

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.4.2
Component: general Version:
Severity: normal Keywords: jinjachecker
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Fixed contrib/jinjachecker not correctly processing multi-line expressions.

Description (last modified by Ryan J Ollos)

./contrib/jinjachecker.py trac/templates/environment_info.html -j
[...]
   51      {IF plugins:
   61            {FOR plugin in plugins:
   62               SET components = plugin.modules|map(attribute='components')|flatten
   65               SET url = (plugin.info.home_page or
   69                {IF url:
[...]

However, markup is:

          # set url = (plugin.info.home_page or
                       plugin.info.author_email and
                       'mailto:' + plugin.info.author_email)

Output of jinjachecker should be:

[...]
   51      {IF plugins:
   61            {FOR plugin in plugins:
   62               SET components = plugin.modules|map(attribute='components')|flatten
   65               SET url = (plugin.info.home_page or
   66                          plugin.info.author_email and
   67                          'mailto:' + plugin.info.author_email)
   69                {IF url:
[...]

Attachments (0)

Change History (7)

comment:1 by Ryan J Ollos, 4 years ago

Related, in r17372 I wrapped the block in a div to avoid this error:

trac/notification/templates/prefs_notification.html:310:10: Element body content does not follow the DTD, expecting (p | h1 | h2 | h3 | h4 | h5 | h6 | div | ul | ol | dl | pre | hr | blockquote | address | fieldset | table | form | noscript | ins | del | script)*, got (h2 div p CDATA)

jinjachecker doesn't recognize the content as being in a block, so the div is needed to avoid an error. The div won't be rendered since it's in a child template and outside a block, so it seems to work fine. Aside, When the script is converted to use pytidylib, maybe the blocks should be extracted and parsed using tidy_fragment?

After fixing the issue in comment:description, a similar issue is seen:

trac/ticket/templates/ticket_change.html:250:8: Element body content does not follow the DTD, expecting (p | h1 | h2 | h3 | h4 | h5 | h6 | div | ul | ol | dl | pre | hr | blockquote | address | fieldset | table | form | noscript | ins | del | script)*, got (a h3 div form div div div div )
# -- HTML 1 errors
One error found.

jinjachecker doesn't recognize the content as being a macro: tags/trac-1.4.1/trac/ticket/templates/ticket_change.html@:43-45#L26.

The reason the fix matters is that before the fix the HTML content discovered by jinjachecker is:

   37
   38
   39                            show_history else max_version)
   40
   41                         comment_version == max_version)
   42
   43
   44 <a href="#comment:${cnum}" class="${cls}">${prefix}${cnum}</a>

This is the same multiline statement problem in comment:description, and seems to obscure jinjachecker from discovering the DTD error.

Last edited 4 years ago by Ryan J Ollos (previous) (diff)

in reply to:  1 comment:2 by Ryan J Ollos, 4 years ago

Replying to Ryan J Ollos:

jinjachecker doesn't recognize the content as being in a block, so the div is needed to avoid an error.

Ah, ## jinjacheck markup can be used to mark the errors as OK.

in reply to:  1 comment:3 by Ryan J Ollos, 4 years ago

Replying to Ryan J Ollos:

The reason the fix matters is that before the fix the HTML content discovered by jinjachecker is:

   37
   38
   39                            show_history else max_version)
   40
   41                         comment_version == max_version)
   42
   43
   44 <a href="#comment:${cnum}" class="${cls}">${prefix}${cnum}</a>

The error is silenced by the jinjacheck: "CDATA" OK.

When that is removed:

trac/ticket/templates/ticket_change.html:249:8: Element body content does not follow the DTD, expecting (p | h1 | h2 | h3 | h4 | h5 | h6 | div | ul | ol | dl | pre | hr | blockquote | address | fieldset | table | form | noscript | ins | del | script)*, got (CDATA a h3 div form div div div div )
# -- HTML 1 errors
One error found.

comment:4 by Ryan J Ollos, 4 years ago

Internal Changes: modified (diff)
Owner: set to Ryan J Ollos
Status: newassigned

comment:5 by Ryan J Ollos, 4 years ago

Resolution: fixed
Status: assignedclosed

Committed in r17404, merged in r17405.

comment:6 by Ryan J Ollos, 4 years ago

Description: modified (diff)

comment:7 by Ryan J Ollos, 4 years ago

Additional changes on trunk for Python 3 in r17484.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.