Parsing bug under Perl 5.6.1, and a fix

Josh Clark <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.html-template
Message-ID <[email protected]>
Here's a strange bug that I encountered while running HTML::Template  
2.8 under Perl 5.006001 (doesn't happen in the various flavors of 5.8  
that I've tried).

When using a scalar reference template, HTML::Template dies on the  
first TMPL_XXX tag that it encounters: "Unknown or unmatched TMPL  
construct at /fake/path/for/non/file/template"

I tweaked the error string to include the value of $which when it  
dies, and I discovered that the TMPL_ portion of the first tag was  
always replaced by F0B5, no matter what the original tag. For example:

TMPL_VAR     -->  F0B5VAR
TMPL_INCLUDE -->  F0B5INCLUDE
TMPL_IF      -->  F0B5IF
etc.

The problem appears to be related to the uc function in line 1969:

     $which = uc($1); # which tag is it

Doing something with $1 (e.g. printing it or assigning it to a  
variable) before calling the uc function fixes the problem.

     $which = $1;
     $which = uc($1); # which tag is it

After making that change, the problem goes away and the template  
string is parsed as usual.

All best,
Josh



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.