You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Henrik Tougaard <ht...@foa.dk> on 2000/08/15 15:15:27 UTC
RE: Bug in Apache::ASP XMLSubs when an argument includes '>'-char
acte rs?
> From: Matt Sergeant [mailto:matt@sergeant.org]
> On Fri, 11 Aug 2000, Henrik Tougaard wrote:
> > With this simple .asp page I get an error:
> >
> > <Fiks:test Start="<b>"> </Fiks:test>
> > [My XMLSubMatch is set to Fiks:\w+ - the name of the
> subroutine doesn't
> > matter]
> >
> > It seems as if the '>' in the '<b>' argument confuses the parser.
>
> [snip]
>
> > Is this a (mis)feature or a parser bug?
>
> parser bug - it should have died earlier at the < sign :-)
>
> XML attributes can't contain "<" or "&" characters, or the
> same quote that
> they are surrounded by. The following are the encodings you can use
> (and XMLSubsMatch needs to unravel):
>
> < => "<"
> > => ">"
> & => "&"
> " => """
> ' => "'"
>
> Note that only "<" is needed for your example (since encoding the
> ">" isn't mandatory in XML generally).
>
Well this does limit the usefullness of the XMLSubs feature.
I had hoped that it would be possbile to use any perl expression in
the attributes - as an easy way of giving arguments to the perl-sub.
Pity....
--
Henrik
Re: Bug in Apache::ASP XMLSubs when an argument includes '>'-characte
rs?
Posted by Joshua Chamas <jo...@chamas.com>.
Henrik Tougaard wrote:
>
> > XML attributes can't contain "<" or "&" characters, or the
> > same quote that
> > they are surrounded by. The following are the encodings you can use
> > (and XMLSubsMatch needs to unravel):
> >
> > < => "<"
> > > => ">"
> > & => "&"
> > " => """
> > ' => "'"
> >
> > Note that only "<" is needed for your example (since encoding the
> > ">" isn't mandatory in XML generally).
> >
> Well this does limit the usefullness of the XMLSubs feature.
> I had hoped that it would be possbile to use any perl expression in
> the attributes - as an easy way of giving arguments to the perl-sub.
>
I think > is just about the only thing that you can't use as
a character in the attributes for an XMLSubs and that's because
it gets parsed with an aggressive ( or stupid ;) regexp like:
$$data =~ s|\<\s*($self->{xml_subs_match})([^\>]*)/\>
So basically what its doing is looking for everything up
to the first > so to put that in the data pretty well kills
it. The arguments are further evaluated from there as $2.
Its simple and fast, and would be really good to keep it
this way.
Note that XMLSubs attributes can be most valid perl expressions,
but I don't think > could be supported in this context either.
Another related XMLSubs attribute issue came up recently
where it was hard to quote the @ character because in perl
"some@email" will error usually, and the quick fix for this
is to have an argument with single quotes like email='some@email'
Internally an XMLSubs attribute will go from
<my:tag email='some@email' range=10 />
to something like
&my::tag(email => 'some@email', range => 10)
-- Joshua
_________________________________________________________________
Joshua Chamas Chamas Enterprises Inc.
NodeWorks >> free web link monitoring Huntington Beach, CA USA
http://www.nodeworks.com 1-714-625-4051
RE: Bug in Apache::ASP XMLSubs when an argument includes '>'-char
acte rs?
Posted by Matt Sergeant <ma...@sergeant.org>.
On Tue, 15 Aug 2000, Henrik Tougaard wrote:
> > XML attributes can't contain "<" or "&" characters, or the
> > same quote that
> > they are surrounded by. The following are the encodings you can use
> > (and XMLSubsMatch needs to unravel):
> >
> > < => "<"
> > > => ">"
> > & => "&"
> > " => """
> > ' => "'"
> >
> > Note that only "<" is needed for your example (since encoding the
> > ">" isn't mandatory in XML generally).
> >
> Well this does limit the usefullness of the XMLSubs feature.
> I had hoped that it would be possbile to use any perl expression in
> the attributes - as an easy way of giving arguments to the perl-sub.
Note that I'm speaking not from Apache::ASP's point of view, but from an
XML point of view. I don't know if Joshua wants to work around these rules
- I certainly never saw a necessity of encoding "<" in an attribute
value. Its not like its really difficult to parse without it. In fact its
_more_ overhead to do it the way the XML spec specifies...
--
<Matt/>
Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org