Menu

#5 predefined XML entities mishandled

closed-fixed
None
5
2001-12-14
2001-05-10
Brian Ewins
No

(posted to psmgl-devel but doesnt seem to have got
through?)
I don't know if this one was recently introduced: the
problem is with DTD-less XML documents which use one
of the standard entities (amp, lt, gt, apos, quot).

psgml-mode complains, eg on this minimal document:
<?xml version="1.0"?>
<foo>
&
</foo>

you get a parse error ar line 3 column 4. C-c C-o
reports:
XML forbids data-entity references in data or DTD (amp)

The error message at line 1695 of psgml-parse.el . I
reckon this is supposed to be applying one of the
rules in section 4.4 of the standard
(http://www.w3.org/TR/2000/REC-xml-20001006#entproc)
but I'm not sure which of kind of entity 'data-entity'
is supposed to be in terms of the xml definitions -
'external parsed general entity' or 'unparsed entity'
I suspect - and the underlying cause may just be that
the 'predefined entities' are wrongly being seen as
one of these types (they should be 'internal general
entities'), or it may be they are not being predefined
at all. I couldn't find any code dealing with them, so
I reckon this could be the underlying cause.

I suspect the problem is wider spread than just dtd-
less documents as the predefined entities are supposed
to be recognized even in the presence of a DTD which
omits them; however many DTDs define them (eg the HTML
DTDs) , masking the underlying problem.

Its worth noting that this document also fails to
parse in exactly the same way:
<?xml version="1.0"?>
<!DOCTYPE foo [
<!ENTITY lt "<">
<!ENTITY gt ">">
<!ENTITY amp "&">
<!ENTITY apos "'">
<!ENTITY quot """>
]>
<foo>
&
</foo>

ie I can't even work around the problem by including
an internal subset. Nor is the problem fixed by
explicity adding the 'standalone' attribute to the XML
PI. This makes me think that something is actually
wrong with the condition that's being checked as well.

If I was to submit a patch for this, where would be
the best place to begin? I thought of altering sgml-
need-dtd but will sgml-xml-p be set on entry? The
simplest fix for me is to do this:
;;(when sgml-xml-p
;; (sgml-error
;; "XML forbids data-entity references in
data or DTD (%s)."
;; name))
but that might have side effects I havent found yet.

Discussion

  • Lennart Staflin

    Lennart Staflin - 2001-05-11
    • assigned_to: nobody --> lenst
     
  • Lennart Staflin

    Lennart Staflin - 2001-12-14

    Logged In: YES
    user_id=30503

    There is a bug in how sgml-warn-about-undefined-entities are
    used. If it is set it will complain about AMP beeing
    undefined. But if it is set, antother (wrong) error message.
    Fixed in next release.

     
  • Lennart Staflin

    Lennart Staflin - 2001-12-14
    • status: open --> closed-fixed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.