[Date Index][Thread Index]
[Date Prev][Date Next][Thread Prev][Thread Next]

[mp4h] Small change in quotes parsing


the files sent by Fritz Zaucker showed that current scheme fails in some
circumstances. I explain below why and what changes have been made.

  <define-tag hello endtag=required>
  <: print "Hello, \"%body\"\n"; :>

  <define-tag message>
  <preserve from>
  <preserve text>
  <set-var %attributes>
  Message from <get-var from>
  <get-var message>
  <restore text>
  <restore from>

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
  <: print Hello, \"blah blah\"
  ; :>

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

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 "
  function ro_imgNormal(imgName) {
      if (document.images) {
          document[imgName].src = eval(imgName + \"_n.src\");
          self.status = '';

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