Skip to content

Certain malformed TMPL_VAR tags are parsed oddly #9

Description

@curtmack

Any tag that looks like this has a weird effect on HTML::Template:

<TMPL_VAR NAME="test"/___>

If the ___ above is replaced by anything other than the empty string, the TMPL_VAR is incorrectly parsed to have the name "test"/ (quotes included). As a result, by default the tag will silently be replaced with nothing (and of course if you provide a parameter named "test"/ it will be substituted as normal).

If a space is included before the /, then the script dies with a syntax error, which I think should be the correct behavior in either case.

Minimal reproduction:

<!-- test.tpl -->
<p><TMPL_VAR NAME="test"/></p>
<p><TMPL_VAR NAME="test"/ ></p>
#!/usr/bin/env perl

# test.pl

use strict;
use warnings;
use HTML::Template;

my $html = HTML::Template->new(filename    => 'test.tpl');

$html->param(test => "This is a test file!");
# $html->param('"test"/' => "This isn't right...");

print $html->output;

Expected output:

HTML::Template->new() : Syntax error in <TMPL_*> tag at test.tpl : 2. at /usr/share/perl5/HTML/Template.pm line 2532.

Actual output:

<!-- test.tpl -->
<p>This is a test file!</p>
<p></p>

Output with the commented line uncommented:

<!-- test.tpl -->
<p>This is a test file!</p>
<p>This isn't right...</p>

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