From kwaclaw at users.sourceforge.net Tue Dec 14 18:24:18 2004
From: kwaclaw at users.sourceforge.net (Karl Waclawek)
Date: Tue Dec 14 18:24:23 2004
Subject: [Expat-checkins] htdocs index.html,1.54,1.55
Message-ID: XML_ParserFree
. Note that if you have
-provided any user data that gets stored in the
+provided any user data that gets stored in the
parser, then your application is responsible for freeing it prior to
calling XML_ParserFree
.
However if However if
XML_SetReturnNSTriplet
has been called with a non-zero
do_nst
parameter, then the expanded form for names with
an explicit prefix is a concatenation of: URI, separator, local name,
From kwaclaw at users.sourceforge.net Fri Dec 17 19:08:26 2004
From: kwaclaw at users.sourceforge.net (Karl Waclawek)
Date: Fri Dec 17 19:08:28 2004
Subject: [Expat-checkins] expat Makefile.in,1.47,1.48
Message-ID: XML_ParserCreateNS
), and the local
name (i.e. the part after the colon). Names with undeclared prefixes
-are passed through to the handlers unchanged, with the prefix and
-colon still attached. Unprefixed attribute names are never expanded,
+are not well-formed when namespace processing is enabled, and will
+trigger an error. Unprefixed attribute names are never expanded,
and unprefixed element names are only expanded when they are in the
scope of a default namespace.
'\0'
: the namespace URI and the local part will be
+concatenated without any separator - this is intended to support RDF processors.
+It is a programming error to use the null separator with
+namespace triplets.
XML_Parser XMLCALL From kwaclaw at users.sourceforge.net Mon Dec 20 06:04:47 2004 From: kwaclaw at users.sourceforge.net (Karl Waclawek) Date: Mon Dec 20 06:04:51 2004 Subject: [Expat-checkins] expat/lib xmlparse.c,1.138,1.139 Message-ID:Update of /cvsroot/expat/expat/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16051 Modified Files: xmlparse.c Log Message: Made it consistent that in the case of namespace triplets, the namespace separator between local name and prefix is always present, even when it is omitted between uri and local name. Index: xmlparse.c =================================================================== RCS file: /cvsroot/expat/expat/lib/xmlparse.c,v retrieving revision 1.138 retrieving revision 1.139 diff -u -d -r1.138 -r1.139 --- xmlparse.c 26 Nov 2004 15:16:17 -0000 1.138 +++ xmlparse.c 20 Dec 2004 05:04:41 -0000 1.139 @@ -2822,7 +2822,7 @@ } if (!step) step = PROBE_STEP(uriHash, mask, nsAttsPower); - j < step ? ( j += nsAttsSize - step) : (j -= step); + j < step ? (j += nsAttsSize - step) : (j -= step); } } @@ -2879,14 +2879,14 @@ prefixLen = 0; if (ns_triplets && binding->prefix->name) { for (; binding->prefix->name[prefixLen++];) - ; + ; /* prefixLen includes null terminator */ } tagNamePtr->localPart = localPart; tagNamePtr->uriLen = binding->uriLen; tagNamePtr->prefix = binding->prefix->name; tagNamePtr->prefixLen = prefixLen; for (i = 0; localPart[i++];) - ; + ; /* i includes null terminator */ n = i + binding->uriLen + prefixLen; if (n > binding->uriAlloc) { TAG *p; @@ -2901,12 +2901,13 @@ FREE(binding->uri); binding->uri = uri; } + /* if namespaceSeparator != '\0' then uri includes it already */ uri = binding->uri + binding->uriLen; memcpy(uri, localPart, i * sizeof(XML_Char)); + /* we always have a namespace separator between localPart and prefix */ if (prefixLen) { - uri = uri + (i - 1); - if (namespaceSeparator) - *uri = namespaceSeparator; + uri += i - 1; + *uri = namespaceSeparator; /* replace null terminator */ memcpy(uri + 1, binding->prefix->name, prefixLen * sizeof(XML_Char)); } tagNamePtr->str = binding->uri; @@ -5286,7 +5287,7 @@ if (!poolAppendChar(&tempPool, XML_T('='))) return NULL; len = dtd->defaultPrefix.binding->uriLen; - if (namespaceSeparator != XML_T('\0')) + if (namespaceSeparator) len--; for (i = 0; i < len; i++) if (!poolAppendChar(&tempPool, dtd->defaultPrefix.binding->uri[i])) @@ -5312,7 +5313,7 @@ if (!poolAppendChar(&tempPool, XML_T('='))) return NULL; len = prefix->binding->uriLen; - if (namespaceSeparator != XML_T('\0')) + if (namespaceSeparator) len--; for (i = 0; i < len; i++) if (!poolAppendChar(&tempPool, prefix->binding->uri[i])) From kwaclaw at users.sourceforge.net Tue Dec 21 19:31:11 2004 From: kwaclaw at users.sourceforge.net (Karl Waclawek) Date: Tue Dec 21 19:31:15 2004 Subject: [Expat-checkins] expat/lib xmlparse.c,1.139,1.140 Message-ID: Update of /cvsroot/expat/expat/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11717 Modified Files: xmlparse.c Log Message: Improved error message - see bug # 972802. Index: xmlparse.c =================================================================== RCS file: /cvsroot/expat/expat/lib/xmlparse.c,v retrieving revision 1.139 retrieving revision 1.140 diff -u -d -r1.139 -r1.140 --- xmlparse.c 20 Dec 2004 05:04:41 -0000 1.139 +++ xmlparse.c 21 Dec 2004 18:30:52 -0000 1.140 @@ -1854,7 +1854,7 @@ XML_L("reference to invalid character number"), XML_L("reference to binary entity"), XML_L("reference to external entity in attribute"), - XML_L("xml declaration not at start of external entity"), + XML_L("XML or text declaration not at start of entity"), XML_L("unknown encoding"), XML_L("encoding specified in XML declaration is incorrect"), XML_L("unclosed CDATA section"), From kwaclaw at users.sourceforge.net Fri Dec 24 17:30:35 2004 From: kwaclaw at users.sourceforge.net (Karl Waclawek) Date: Fri Dec 24 17:30:38 2004 Subject: [Expat-checkins] expat/lib xmlparse.c,1.140,1.141 Message-ID: Update of /cvsroot/expat/expat/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32236 Modified Files: xmlparse.c Log Message: Fix for bug # 1090885: Problem with Suspend/Resume mechanism. The code path through XML_Parse() when XML_CONTEXT_BYTES was not defined, did not take into account that XML_ResumParser() uses bufferPtr and parseEndPtr as the pointers into the working buffer. Index: xmlparse.c =================================================================== RCS file: /cvsroot/expat/expat/lib/xmlparse.c,v retrieving revision 1.140 retrieving revision 1.141 diff -u -d -r1.140 -r1.141 --- xmlparse.c 21 Dec 2004 18:30:52 -0000 1.140 +++ xmlparse.c 24 Dec 2004 16:30:25 -0000 1.141 @@ -1441,7 +1441,7 @@ /* If data are left over from last buffer, and we now know that these data are the final chunk of input, then we have to check them again - to detect errors based on this information. + to detect errors based on that fact. */ errorCode = processor(parser, bufferPtr, parseEndPtr, &bufferPtr); @@ -1495,7 +1495,6 @@ } XmlUpdatePosition(encoding, positionPtr, end, &position); - positionPtr = end; nLeftOver = s + len - end; if (nLeftOver) { if (buffer == NULL || nLeftOver > bufferLim - buffer) { @@ -1518,9 +1517,13 @@ bufferLim = buffer + len * 2; } memcpy(buffer, end, nLeftOver); - bufferPtr = buffer; - bufferEnd = buffer + nLeftOver; } + bufferPtr = buffer; + bufferEnd = buffer + nLeftOver; + positionPtr = bufferPtr; + parseEndPtr = bufferEnd; + eventPtr = bufferPtr; + eventEndPtr = bufferPtr; return result; } #endif /* not defined XML_CONTEXT_BYTES */ From kwaclaw at users.sourceforge.net Fri Dec 24 19:00:31 2004 From: kwaclaw at users.sourceforge.net (Karl Waclawek) Date: Fri Dec 24 19:00:34 2004 Subject: [Expat-checkins] expat/lib expat.h, 1.74, 1.75 xmlparse.c, 1.141, 1.142 Message-ID: Update of /cvsroot/expat/expat/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16464 Modified Files: expat.h xmlparse.c Log Message: Fix for bug # 695407: Reserved prefixes and namespace names. Contributed by Peter van der Beken. Index: expat.h =================================================================== RCS file: /cvsroot/expat/expat/lib/expat.h,v retrieving revision 1.74 retrieving revision 1.75 diff -u -d -r1.74 -r1.75 --- expat.h 20 Dec 2004 03:19:09 -0000 1.74 +++ expat.h 24 Dec 2004 18:00:28 -0000 1.75 @@ -91,7 +91,11 @@ XML_ERROR_NOT_SUSPENDED, XML_ERROR_ABORTED, XML_ERROR_FINISHED, - XML_ERROR_SUSPEND_PE + XML_ERROR_SUSPEND_PE, + /* Added in 2.0. */ + XML_ERROR_RESERVED_PREFIX_XML, + XML_ERROR_RESERVED_PREFIX_XMLNS, + XML_ERROR_RESERVED_NAMESPACE_URI }; enum XML_Content_Type { Index: xmlparse.c =================================================================== RCS file: /cvsroot/expat/expat/lib/xmlparse.c,v retrieving revision 1.141 retrieving revision 1.142 diff -u -d -r1.141 -r1.142 --- xmlparse.c 24 Dec 2004 16:30:25 -0000 1.141 +++ xmlparse.c 24 Dec 2004 18:00:28 -0000 1.142 @@ -1877,7 +1877,10 @@ XML_L("parser not suspended"), XML_L("parsing aborted"), XML_L("parsing finished"), - XML_L("cannot suspend in external parameter entity") + XML_L("cannot suspend in external parameter entity"), + XML_L("reserved prefix (xml) must not be undeclared or bound to another namespace name"), + XML_L("reserved prefix (xmlns) must not be declared or undeclared"), + XML_L("prefix must not be bound to one of the reserved namespace names") }; if (code > 0 && code < sizeof(message)/sizeof(message[0])) return message[code]; @@ -2931,8 +2934,64 @@ if (*uri == XML_T('\0') && prefix->name) return XML_ERROR_UNDECLARING_PREFIX; - for (len = 0; uri[len]; len++) - ; + if (ns) { + static const XML_Char xmlNamespace[] = { + 'h', 't', 't', 'p', ':', '/', '/', + 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', + 'X', 'M', 'L', '/', '1', '9', '9', '8', '/', + 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\0' + }; + static const int xmlLen = + (int)sizeof(xmlNamespace)/sizeof(XML_Char) - 1; + static const XML_Char xmlnsNamespace[] = { + 'h', 't', 't', 'p', ':', '/', '/', + 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', + '2', '0', '0', '0', '/', 'x', 'm', 'l', 'n', 's', '/', '\0' + }; + static const int xmlnsLen = + (int)sizeof(xmlnsNamespace)/sizeof(XML_Char) - 1; + + XML_Bool mustBeXML = XML_FALSE; + XML_Bool isXML = XML_TRUE; + XML_Bool isXMLNS = XML_TRUE; + + if (prefix->name + && prefix->name[0] == XML_T('x') + && prefix->name[1] == XML_T('m') + && prefix->name[2] == XML_T('l')) { + + /* Not allowed to bind xmlns */ + if (prefix->name[3] == XML_T('n') + && prefix->name[4] == XML_T('s') + && prefix->name[5] == XML_T('\0')) + return XML_ERROR_RESERVED_PREFIX_XMLNS; + + if (prefix->name[3] == XML_T('\0')) + mustBeXML = XML_TRUE; + } + + for (len = 0; uri[len]; len++) { + if (isXML && (len > xmlLen || uri[len] != xmlNamespace[len])) + isXML = XML_FALSE; + + if (!mustBeXML && isXMLNS + && (len > xmlnsLen || uri[len] != xmlnsNamespace[len])) + isXMLNS = XML_FALSE; + } + isXML = isXML && len == xmlLen; + isXMLNS = isXMLNS && len == xmlnsLen; + + if (mustBeXML != isXML) + return mustBeXML ? XML_ERROR_RESERVED_PREFIX_XML + : XML_ERROR_RESERVED_NAMESPACE_URI; + + if (isXMLNS) + return XML_ERROR_RESERVED_NAMESPACE_URI; + } + else + for (len = 0; uri[len]; len++) + ; + if (namespaceSeparator) len++; if (freeBindingList) { From kwaclaw at users.sourceforge.net Fri Dec 24 19:25:35 2004 From: kwaclaw at users.sourceforge.net (Karl Waclawek) Date: Fri Dec 24 19:25:38 2004 Subject: [Expat-checkins] expat/lib xmlparse.c,1.142,1.143 Message-ID: Update of /cvsroot/expat/expat/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21975 Modified Files: xmlparse.c Log Message: "if (ns)" check in addBinding() is not necessary, since it is only called when namespace processing is turned on. Index: xmlparse.c =================================================================== RCS file: /cvsroot/expat/expat/lib/xmlparse.c,v retrieving revision 1.142 retrieving revision 1.143 diff -u -d -r1.142 -r1.143 --- xmlparse.c 24 Dec 2004 18:00:28 -0000 1.142 +++ xmlparse.c 24 Dec 2004 18:25:32 -0000 1.143 @@ -2927,6 +2927,26 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, const XML_Char *uri, BINDING **bindingsPtr) { + static const XML_Char xmlNamespace[] = { + 'h', 't', 't', 'p', ':', '/', '/', + 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', + 'X', 'M', 'L', '/', '1', '9', '9', '8', '/', + 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\0' + }; + static const int xmlLen = + (int)sizeof(xmlNamespace)/sizeof(XML_Char) - 1; + static const XML_Char xmlnsNamespace[] = { + 'h', 't', 't', 'p', ':', '/', '/', + 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', + '2', '0', '0', '0', '/', 'x', 'm', 'l', 'n', 's', '/', '\0' + }; + static const int xmlnsLen = + (int)sizeof(xmlnsNamespace)/sizeof(XML_Char) - 1; + + XML_Bool mustBeXML = XML_FALSE; + XML_Bool isXML = XML_TRUE; + XML_Bool isXMLNS = XML_TRUE; + BINDING *b; int len; @@ -2934,63 +2954,38 @@ if (*uri == XML_T('\0') && prefix->name) return XML_ERROR_UNDECLARING_PREFIX; - if (ns) { - static const XML_Char xmlNamespace[] = { - 'h', 't', 't', 'p', ':', '/', '/', - 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', - 'X', 'M', 'L', '/', '1', '9', '9', '8', '/', - 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\0' - }; - static const int xmlLen = - (int)sizeof(xmlNamespace)/sizeof(XML_Char) - 1; - static const XML_Char xmlnsNamespace[] = { - 'h', 't', 't', 'p', ':', '/', '/', - 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', - '2', '0', '0', '0', '/', 'x', 'm', 'l', 'n', 's', '/', '\0' - }; - static const int xmlnsLen = - (int)sizeof(xmlnsNamespace)/sizeof(XML_Char) - 1; - - XML_Bool mustBeXML = XML_FALSE; - XML_Bool isXML = XML_TRUE; - XML_Bool isXMLNS = XML_TRUE; - - if (prefix->name - && prefix->name[0] == XML_T('x') - && prefix->name[1] == XML_T('m') - && prefix->name[2] == XML_T('l')) { + if (prefix->name + && prefix->name[0] == XML_T('x') + && prefix->name[1] == XML_T('m') + && prefix->name[2] == XML_T('l')) { - /* Not allowed to bind xmlns */ - if (prefix->name[3] == XML_T('n') - && prefix->name[4] == XML_T('s') - && prefix->name[5] == XML_T('\0')) - return XML_ERROR_RESERVED_PREFIX_XMLNS; + /* Not allowed to bind xmlns */ + if (prefix->name[3] == XML_T('n') + && prefix->name[4] == XML_T('s') + && prefix->name[5] == XML_T('\0')) + return XML_ERROR_RESERVED_PREFIX_XMLNS; - if (prefix->name[3] == XML_T('\0')) - mustBeXML = XML_TRUE; - } + if (prefix->name[3] == XML_T('\0')) + mustBeXML = XML_TRUE; + } - for (len = 0; uri[len]; len++) { - if (isXML && (len > xmlLen || uri[len] != xmlNamespace[len])) - isXML = XML_FALSE; + for (len = 0; uri[len]; len++) { + if (isXML && (len > xmlLen || uri[len] != xmlNamespace[len])) + isXML = XML_FALSE; - if (!mustBeXML && isXMLNS - && (len > xmlnsLen || uri[len] != xmlnsNamespace[len])) - isXMLNS = XML_FALSE; - } - isXML = isXML && len == xmlLen; - isXMLNS = isXMLNS && len == xmlnsLen; + if (!mustBeXML && isXMLNS + && (len > xmlnsLen || uri[len] != xmlnsNamespace[len])) + isXMLNS = XML_FALSE; + } + isXML = isXML && len == xmlLen; + isXMLNS = isXMLNS && len == xmlnsLen; - if (mustBeXML != isXML) - return mustBeXML ? XML_ERROR_RESERVED_PREFIX_XML - : XML_ERROR_RESERVED_NAMESPACE_URI; + if (mustBeXML != isXML) + return mustBeXML ? XML_ERROR_RESERVED_PREFIX_XML + : XML_ERROR_RESERVED_NAMESPACE_URI; - if (isXMLNS) - return XML_ERROR_RESERVED_NAMESPACE_URI; - } - else - for (len = 0; uri[len]; len++) - ; + if (isXMLNS) + return XML_ERROR_RESERVED_NAMESPACE_URI; if (namespaceSeparator) len++;