Re: [PATCH] Compiler fatal error on unbalanced content tags
John Williams <[email protected]> Thu, 7 Jun 2007 15:06:16 -0600 (MDT)
| Newsgroups | gmane.comp.web.mason.devel |
|---|---|
| Message-ID | <[email protected]> |
This looks good, thanks. Unfortunately, I have forgotten my password to the svn repository. I guess I'm not contributing much lately. Dave, can you apply this patch? I've added a Changes entry, and another test, since I didn't see any test explicitly for using <&| inside a subcomponent. ~ John Williams On Thu, 7 Jun 2007, Rich Williams wrote: > All, > > I had a stray </&> in a %method, and the compiler died ... > > Can't use an undefined value as an ARRAY reference at > .../HTML/Mason/Compiler.pm line 566 > > It's the test which is checking for balanced tags which is failing - > it works fine for top level components, but not for %def or %method, > because comp_with_content_stack is only initialised in > start_component, which (as far as I can tell) isn't called for > sub-components. > > The attached patch simply changes the test a little (a similar method > is used elsewhere in Compiler.pm). I've also added two new test cases, > one to catch unbalanced content ending tags in top-level components, > and one to catch them in sub-components. > > Hope this helps. > > Have fun, > > Rich > ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Mason-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mason-devel
richwilliams.patch
(text/plain, 2.9 KB)
Index: t/09a-comp_content.t
===================================================================
--- t/09a-comp_content.t (revision 3835)
+++ t/09a-comp_content.t (working copy)
@@ -540,6 +540,26 @@
#------------------------------------------------------------
+ $group->add_test( name => 'inside subcomp',
+ description => 'call comp-with-content inside subcomp',
+ component => <<'EOF',
+<& .subcomp &>
+<%def .subcomp>\
+<&| .uc &>\
+hello
+</&>
+</%def>
+<%def .uc>\
+% $m->print(uc($m->content));
+</%def>
+EOF
+ expect => <<'EOF',
+HELLO
+EOF
+ );
+
+#------------------------------------------------------------
+
return $group;
}
Index: t/06-compiler.t
===================================================================
--- t/06-compiler.t (revision 3835)
+++ t/06-compiler.t (working copy)
@@ -1105,6 +1105,30 @@
#------------------------------------------------------------
+ $group->add_test( name => 'unbalanced_content_block_error',
+ description => 'Detect and report unbalanced </&> tags',
+ interp_params => { enable_autoflush => 0 },
+ component => <<'EOF',
+</&>
+EOF
+ expect_error => qr/content ending tag but no beginning tag/
+ );
+
+#------------------------------------------------------------
+
+ $group->add_test( name => 'unbalanced_content_block_subcomp_error',
+ description => 'Detect and report unbalanced </&> tags in subcomponents',
+ interp_params => { enable_autoflush => 0 },
+ component => <<'EOF',
+<%def test>
+</&>
+</%def>
+EOF
+ expect_error => qr/content ending tag but no beginning tag/
+ );
+
+#------------------------------------------------------------
+
return $group;
}
Index: lib/HTML/Mason/Compiler.pm
===================================================================
--- lib/HTML/Mason/Compiler.pm (revision 3835)
+++ lib/HTML/Mason/Compiler.pm (working copy)
@@ -566,7 +566,7 @@
my %p = @_;
$self->lexer->throw_syntax_error("Found component with content ending tag but no beginning tag")
- unless @{ $c->{comp_with_content_stack} };
+ unless $c->{comp_with_content_stack} && @{ $c->{comp_with_content_stack} };
my $call = pop @{ $c->{comp_with_content_stack} };
my $call_end = $p{call_end};
Index: Changes
===================================================================
--- Changes (revision 3835)
+++ Changes (working copy)
@@ -5,6 +5,12 @@
** denotes an incompatible change
+[ BUG FIXES ]
+
+- An unbalanced </&> tag inside a subcomponent made the compiler die.
+ Reported (with patch) by Rich Williams.
+
+
1.36
[ BUG FIXES ]