Edgewall Software
Modify

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#9569 closed defect (invalid)

Javascript comparison operator '&&' throws exception in templates/ticket.html

Reported by: nbalkanas@… Owned by:
Priority: normal Milestone:
Component: ticket system Version: 0.11.6
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Remy Blank)

Problem is always there. It should be easy to reproduce. In <project>/templates/ticket.html the following code:

<script language="Javascript" type="text/javascript">
       function check_ticket(thisform)
       {
           with(thisform)
           {
               var diagnostics = field_diagnostic_info.value.split(" ");

               if (field_diagnostic_info.value.length == 126 &&
                   diagnostics[0] == "Please")
               {
                   alert("Please provide errors and diagnostic messages.");
                   field_diagnostic_info.focus();
                   return(false);
               }
           }
           return(true);
        }
</script>

will throw internal error on token '&&':

Trac detected an internal error: 
TemplateSyntaxError: not well-formed (invalid token): line 49, column 62 (/var/trac/projects/ianwap/templates/ticket.html, line 49)

Python Traceback
Most recent call last: 
File "/usr/lib/python2.3/site-packages/Trac-0.11.6-py2.3.egg/trac/web/main.py", line 450, in _dispatch_request 
File "/usr/lib/python2.3/site-packages/Trac-0.11.6-py2.3.egg/trac/web/main.py", line 227, in dispatch 
File "/usr/lib/python2.3/site-packages/Trac-0.11.6-py2.3.egg/trac/web/chrome.py", line 738, in render_template 
File "/usr/lib/python2.3/site-packages/Trac-0.11.6-py2.3.egg/trac/web/chrome.py", line 712, in load_template 
File "/usr/lib/python2.3/site-packages/Genshi-0.5.1-py2.3-linux-i686.egg/genshi/template/loader.py", line 227, in load 
File "/usr/lib/python2.3/site-packages/Genshi-0.5.1-py2.3-linux-i686.egg/genshi/template/loader.py", line 265, in _instantiate 
File "/usr/lib/python2.3/site-packages/Genshi-0.5.1-py2.3-linux-i686.egg/genshi/template/base.py", line 379, in __init__
Trac:	0.11.6
Python:	2.3.4 (#1, Feb 15 2005, 19:42:48) [GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)]
setuptools:	0.6c9
SQLite:	3.3.6
pysqlite:	1.1.7
Genshi:	0.5.1
mod_python:	< 3.2
jQuery:	1.2.6

Attachments (0)

Change History (3)

comment:1 by Remy Blank, 14 years ago

Description: modified (diff)
Resolution: invalid
Status: newclosed

That's because your code is invalid (when included in an HTML file). You have to either escape the & characters by substituting with &amp; or enclose the code in a CDATA section.

comment:2 by nbalkanas@…, 14 years ago

I don't understand what you mean. Javascipt is defined in <head> section of ticket.html and works fine when loaded directly from the browser. That's how Javascripts work.

Upon using your suggestion, I get no Trac internal errors, however, the &amp; and CDATA remain unchanged to the output Javascript, which doesn't work. Have you tried it?

comment:3 by Remy Blank, 14 years ago

Yes, I have. You should use either &amp; or the CDATA section, but not both. The CDATA is more readable.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) 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.