#50 Patch for bug # 566334

closed-accepted
None
8
2002-06-13
2002-06-10
No

This patch tries to fix the problem with wrong
names reported in the endElement handler, when
namespace processing is on.

The reason for the problem is that Expat passes
the buffer for the namespace URI to the handler,
copying the element's local name (and prefix) to
the end of the buffer, right after the URI.
This saves re-copying the URI.

However, if multiple nested elements use the same
namespace URI, the names of the top elements
get overwritten, since only one buffer is used,
and therefore the endElement handler will only
report the name of the last, most deeply nested
element .

I have tried to fix this by re-copying localPart
and prefix before the endelement handler is called.
Another approach could have been to use separate
buffers (e.g. tag->buf), but this would have meant
copying the whole URI for each element in the
namespace, so I think the solution I tried is
at least as efficient.

This type of solution was already tried once by
the user "maki", but only for NSTriplets reporting,
not for NS processing in general.

The patch applies to xmlparse.c rev. 1.44.

Please test thoroughly - this patch needs
to be done right.

Karl

Discussion

  • Karl Waclawek

    Karl Waclawek - 2002-06-10

    Diff file for patch

     
  • Fred L. Drake, Jr.

    Logged In: YES
    user_id=3066

    Your description of the problem and proposed solution sounds
    good, and a quick test of your patch using xmlwf works.
    I'll see if I can knock out a quick test case for this for
    the regression suite.

     
  • Karl Waclawek

    Karl Waclawek - 2002-06-12

    Logged In: YES
    user_id=290026

    If you go back to 1.95.2, you will see that a similar
    approach was used, except for the NSTriplets part,
    of course.

    Btw, if you find my coding inefficient or simply
    sub-optimal, please feel free to correct.

    Karl

     
  • Fred L. Drake, Jr.

    Logged In: YES
    user_id=3066

    I've attached a patch to tests/runtests.c that adds tests
    for this, both with and without NS triplets enabled. I
    think this patch should be checked in and closed (along with
    the bug).

    If there are further problems, additional reports can be filed.

    (This is the advantage of "release early, release often",
    which we should do whenever possible.)

     
  • Fred L. Drake, Jr.

    • status: open --> open-accepted
     
  • Fred L. Drake, Jr.

    regression tests

     
  • Karl Waclawek

    Karl Waclawek - 2002-06-13

    Logged In: YES
    user_id=290026

    Patch checked in.

    Karl

     
  • Karl Waclawek

    Karl Waclawek - 2002-06-13
    • status: open-accepted --> closed-accepted
     

Log in to post a comment.