[Date Index][Thread Index]
[Date Prev][Date Next][Thread Prev][Thread Next]
[mp4h] Small change in quotes parsing
- From: Denis Barbier <nospam@thanx>
- Date: Sat, 22 Jul 2000 22:55:54 +0200
Hi,
the files sent by Fritz Zaucker showed that current scheme fails in some
circumstances. I explain below why and what changes have been made.
Consider
<define-tag hello endtag=required>
<: print "Hello, \"%body\"\n"; :>
</define-tag>
<define-tag message>
<preserve from>
<preserve text>
<set-var %attributes>
Message from <get-var from>
<BLOCKQUOTE>
<get-var message>
</BLOCKQUOTE>
<restore text>
<restore from>
</define-tag>
Now try to compile
<message from=Bob text="<hello>blah blah</hello>">
Why does it fail?
Because macro arguments are first divided into attributes (and quotes
are removed during this phase), then attributes are expanded. So this
line becomes after processing by wml_p2_mp4h
Message from Bob
<BLOCKQUOTE>
<: print Hello, \"blah blah\"
; :>
</BLOCKQUOTE>
The idea is to remember that quotes have a special role in attributes
only. So it is safe to mark quotes not residing in attributes as
immutable, i.e. they are never removed even if they become part of some
attributes.
It is very simple and this is why i am much more confident with this new
approach. But it will break one case, which appears in wml::des::rollover.
A simpler version is
<group "
<javascript>
function ro_imgNormal(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + \"_n.src\");
self.status = '';
}
}
</javascript>
">
Now, \" is no more processed as an escaped quote in string (and remember
how <hello> is defined, we do not want this behaviour anymore). So it
must be replaced by normal double quotes.
This should appear in very rarely.
To prevent other problems with quotes, it is wise to replace double
quotes by single quotes whenever possible (e.g. in lines above), or by
Perl q and qq operators.
--
Denis Barbier
WML Maintainer
______________________________________________________________________
Website META Language (WML) www.engelschall.com/sw/wml/
Official Support Mailing List sw-wml@engelschall.com
Automated List Manager majordomo@engelschall.com