#57 Enable undeclared DTD

closed-accepted
Karl Waclawek
None
5
2002-08-27
2002-08-24
Karl Waclawek
No

SAX2 provides the ability to use a customer provided
external DTD when there is no external subset. Check
out the definition of getExternalSubset on this page:

http://sax.sourceforge.net/apidoc/org/xml/sax/ext/Entity
Resolver2.html

I patched Expat to enable such behaviour.
When the user calls the new API function
XML_UseForeignDTD() with an argument of XML_TRUE,
then the externalEntityRefHandler will be called
even if there is no external subset/DTD declared.
In such a case the systemId argument will be NULL.

A "foreign DTD" would be interpreted just as if
the document had an external subset reference,
that is, the internal field dtd.hasParamEntityRefs
would become true.

Patch attached.
This patch also includes additional improvements/fixes
that became apparent when working on the patch.
These affect the function dtdReset() and the
notStandaloneHandler().

Discussion

  • Karl Waclawek
    Karl Waclawek
    2002-08-24

    Patch enabling parsing of undeclared DTD

     
    Attachments
  • Karl Waclawek
    Karl Waclawek
    2002-08-24

    Small improvement to patch

     
    Attachments
  • Karl Waclawek
    Karl Waclawek
    2002-08-24

    Logged In: YES
    user_id=290026

    Made small improvement to patch.

    Thinking about changing the API from
    XML_UseForeignDTD(parser, useDTD)
    to
    XML_SetUseForeignDTDHandler(parser, callback).

    The value of the internal field useForeignDTD is used only
    once, but updated multiple times. With the orginal API
    the caller has write access to this field and can
    potentially mess up the logic, with the new one, the parser
    reads it when it needs it, and then has full control.

    Comments?

     
  • Karl Waclawek
    Karl Waclawek
    2002-08-25

    Patch with safety feature added

     
    Attachments
  • Karl Waclawek
    Karl Waclawek
    2002-08-25

    Logged In: YES
    user_id=290026

    I added the macro
    #define parsing (processor != prologInitProcessor)
    which returns true once XML_Parse or XML_ParseBuffer
    has been called. This is used to block setting of the
    useForeignDTD flag when parsing is under way.

    I have also applied this logic to these other functions:
    XML_SetEncoding
    XML_SetParamEntityParsing
    XML_SetReturnNSTriplets
    Since there is a chance that parser logic might get
    upset if the corresponding flags are changed after
    parsing has begun.

    New patch version attached with description
    "Patch with safety feature added".

     
  • Logged In: YES
    user_id=3066

    Isn't this already checked in? Please close it when you're
    done.

     
  • Karl Waclawek
    Karl Waclawek
    2002-08-27

    • status: open --> closed-accepted
     
  • Karl Waclawek
    Karl Waclawek
    2002-08-27

    Logged In: YES
    user_id=290026

    Checked in.