[xml] Sax Structured Error Handler Overriden



Hi everyone,

My name is Charlie Savage and I've recently took over maintenance of the libxml bindings for Ruby (http://libxml.rubyforge.org/).

I recently switched over the bindings to use libxml's structured error handling functionality.

That worked well until I then switched the SAX parser to use Sax2 and the sax specific structured error handler. I was surprised to find that the Sax structured error handler is never called - only the global one is.

I've submitted the bug in bugzilla here:

http://bugzilla.gnome.org/show_bug.cgi?id=564217

What's happening is that the __xmlRaiseError method correctly finds the sax structured error handler around line 464 in error.c:

if ((schannel == NULL) && (ctxt != NULL) && (ctxt->sax != NULL) &&
            (ctxt->sax->initialized == XML_SAX2_MAGIC))
            schannel = ctxt->sax->serror;
    }

But then incorrectly overrides is down around line 605:

    } else if (channel == NULL) {
        if (xmlStructuredError != NULL)
            schannel = xmlStructuredError;

channel is null because that's how xmlFatalErrMsgStrIntStr calls it when a fatal error occurs in a Sax parser.

In my view the code should not override schannel if it is already set, so like this:

    } else if (channel == NULL) {
        if (schannel == NULL && xmlStructuredError != NULL)
            schannel = xmlStructuredError;

Without this change, ctxt->sax->serror turns out to be fairly useless if you are using a global strucutred error handler (which seems much preferable to the generic error handler).

Thoughts?


Thanks,

Charlie


--
Charlie Savage
http://cfis.savagexi.com

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature



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