Closed Bug 291020 Opened 19 years ago Closed 19 years ago

[FIXr]XML mismatched tag error wrong when namespaces are involved

Categories

(Core :: XML, defect, P1)

x86
Linux
defect

Tracking

()

RESOLVED FIXED
mozilla1.8beta2

People

(Reporter: bzbarsky, Assigned: bzbarsky)

References

()

Details

Attachments

(1 file)

The document in the URL field should say that a "</foo>" is expected.  Instead,
it says that a "</bar>" is expected, which is bogus.

This has been broken basically since the new expat landing.  Patch coming up,
though I have to say that the implications of the comments in this code scare me
a little...
Attached patch PatchSplinter Review
Attachment #181185 - Flags: superreview?(peterv)
Attachment #181185 - Flags: review?(peterv)
Priority: -- → P1
Summary: XML mismatched tag error wrong when namespaces are involved → [FIX]XML mismatched tag error wrong when namespaces are involved
Target Milestone: --- → mozilla1.8beta2
Comment on attachment 181185 [details] [diff] [review]
Patch

>Index: parser/expat/lib/xmlparse.c
>===================================================================
>RCS file: /home/bzbarsky/mozilla/cvs-mirror/mozilla/parser/expat/lib/xmlparse.c,v
>retrieving revision 1.29
>diff -u -p -d -2 -5 -r1.29 xmlparse.c
>--- parser/expat/lib/xmlparse.c	13 Jan 2005 14:51:20 -0000	1.29
>+++ parser/expat/lib/xmlparse.c	19 Apr 2005 19:55:55 -0000
>@@ -2331,54 +2331,74 @@ doContent(XML_Parser parser,
>           if (endNamespaceDeclHandler)
>             endNamespaceDeclHandler(handlerArg, b->prefix->name);
>           bindings = bindings->nextTagBinding;
>           b->nextTagBinding = freeBindingList;
>           freeBindingList = b;
>           b->prefix->binding = b->prevPrefixBinding;
>         }
>       }
>       if (tagLevel == 0)
>         return epilogProcessor(parser, next, end, nextPtr);
>       break;
>     case XML_TOK_END_TAG:
>       if (tagLevel == startTagLevel)
>         return XML_ERROR_ASYNC_ENTITY;
>       else {
>         int len;
>         const char *rawName;
>         TAG *tag = tagStack;
>         tagStack = tag->parent;
>         tag->parent = freeTagList;
>         freeTagList = tag;
>         rawName = s + enc->minBytesPerChar*2;
>         len = XmlNameLength(enc, rawName);
>         if (len != tag->rawNameLength
>             || memcmp(tag->rawName, rawName, len) != 0) {
>-          *eventPP = rawName;
> /* BEGIN MOZILLA CHANGE (Report opening tag of mismatched closing tag) */
>+	  // This code is copied from the |if (endElementHandler)| block below
>+          const XML_Char *localPart;
>+          const XML_Char *prefix;
>+          XML_Char *uri;
>+          localPart = tag->name.localPart;
>+          if (ns && localPart) {
>+            /* localPart and prefix may have been overwritten in
>+               tag->name.str, since this points to the binding->uri
>+               buffer which gets re-used; so we have to add them again
>+            */
>+            uri = (XML_Char *)tag->name.str + tag->name.uriLen;
>+            /* don't need to check for space - already done in storeAtts() */
>+            while (*localPart) *uri++ = *localPart++;
>+            prefix = (XML_Char *)tag->name.prefix;
>+            if (ns_triplets && prefix) {
>+              *uri++ = namespaceSeparator;
>+              while (*prefix) *uri++ = *prefix++;
>+             }
>+            *uri = XML_T('\0');
>+          }
>           mismatch = tag->name.str;
> /* END MOZILLA CHANGE */
>+          *eventPP = rawName;
>           return XML_ERROR_TAG_MISMATCH;
>         }
>         --tagLevel;
>         if (endElementHandler) {
>           const XML_Char *localPart;
>           const XML_Char *prefix;
>           XML_Char *uri;
>           localPart = tag->name.localPart;
>           if (ns && localPart) {
>             /* localPart and prefix may have been overwritten in
>                tag->name.str, since this points to the binding->uri
>                buffer which gets re-used; so we have to add them again
>             */
>             uri = (XML_Char *)tag->name.str + tag->name.uriLen;
>             /* don't need to check for space - already done in storeAtts() */
>             while (*localPart) *uri++ = *localPart++;
>             prefix = (XML_Char *)tag->name.prefix;
>             if (ns_triplets && prefix) {
>               *uri++ = namespaceSeparator;
>               while (*prefix) *uri++ = *prefix++;
>              }
>             *uri = XML_T('\0');
>           }
>           endElementHandler(handlerArg, tag->name.str);
> /* BEGIN MOZILLA CHANGE (Blocking parser) */
Attachment #181185 - Flags: superreview?(peterv)
Attachment #181185 - Flags: superreview+
Attachment #181185 - Flags: review?(peterv)
Attachment #181185 - Flags: review+
Comment on attachment 181185 [details] [diff] [review]
Patch

Requesting 1.8b2 approval.  This makes sure we actually write the data we want
to get to memory before we try to get it...
Attachment #181185 - Flags: approval1.8b2?
Summary: [FIX]XML mismatched tag error wrong when namespaces are involved → [FIXr]XML mismatched tag error wrong when namespaces are involved
Comment on attachment 181185 [details] [diff] [review]
Patch

a=asa
Attachment #181185 - Flags: approval1.8b2? → approval1.8b2+
Fixed (with the C++ comment changed to a C one).
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: