[3.10] gh-146083: Upgrade bundled Expat to 2.7.5 (GH-146085) by StanFromIreland · Pull Request #146608 · python/cpython
@@ -1,4 +1,4 @@
/* fab937ab8b186d7d296013669c332e6dfce2f99567882cff1f8eb24223c524a7 (2.7.4+)
/* 93c1caa66e2b0310459482516af05505b57c5cb7b96df777105308fc585c85d1 (2.7.5+)
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
Expand Down
Expand Up
@@ -590,6 +590,8 @@ static XML_Char *poolStoreString(STRING_POOL *pool, const ENCODING *enc,
static XML_Bool FASTCALL poolGrow(STRING_POOL *pool);
static const XML_Char *FASTCALL poolCopyString(STRING_POOL *pool,
const XML_Char *s);
static const XML_Char *FASTCALL poolCopyStringNoFinish(STRING_POOL *pool,
const XML_Char *s);
static const XML_Char *poolCopyStringN(STRING_POOL *pool, const XML_Char *s,
int n);
static const XML_Char *FASTCALL poolAppendString(STRING_POOL *pool,
Expand Down
Expand Up
@@ -5086,7 +5088,7 @@ entityValueInitProcessor(XML_Parser parser, const char *s, const char *end,
}
/* If we get this token, we have the start of what might be a
normal tag, but not a declaration (i.e. it doesn't begin with
"<!"). In a DTD context, that isn't legal.
"<!" or "<?"). In a DTD context, that isn't legal.
*/
else if (tok == XML_TOK_INSTANCE_START) {
*nextPtr = next;
Expand Down
Expand Up
@@ -5175,6 +5177,15 @@ entityValueProcessor(XML_Parser parser, const char *s, const char *end,
/* found end of entity value - can store it now */
return storeEntityValue(parser, enc, s, end, XML_ACCOUNT_DIRECT, NULL);
}
/* If we get this token, we have the start of what might be a
normal tag, but not a declaration (i.e. it doesn't begin with
"<!" or "<?"). In a DTD context, that isn't legal.
*/
else if (tok == XML_TOK_INSTANCE_START) {
*nextPtr = next;
return XML_ERROR_SYNTAX;
}
start = next; } }Expand Down
Expand Up
@@ -6789,7 +6800,14 @@ storeEntityValue(XML_Parser parser, const ENCODING *enc,
return XML_ERROR_NO_MEMORY;
}
const char *next; const char *next = entityTextPtr;
/* Nothing to tokenize. */ if (entityTextPtr >= entityTextEnd) { result = XML_ERROR_NONE; goto endEntityValue; }
for (;;) { next = entityTextPtr; /* XmlEntityValueTok doesn't always set the last arg */Expand Down
Expand Up
@@ -7439,16 +7457,24 @@ setContext(XML_Parser parser, const XML_Char *context) {
else {
if (! poolAppendChar(&parser->m_tempPool, XML_T('\0')))
return XML_FALSE;
prefix
= (PREFIX *)lookup(parser, &dtd->prefixes,
poolStart(&parser->m_tempPool), sizeof(PREFIX));
if (! prefix)
const XML_Char *const prefixName = poolCopyStringNoFinish(
&dtd->pool, poolStart(&parser->m_tempPool));
if (! prefixName) {
return XML_FALSE;
if (prefix->name == poolStart(&parser->m_tempPool)) {
prefix->name = poolCopyString(&dtd->pool, prefix->name);
if (! prefix->name)
return XML_FALSE;
}
prefix = (PREFIX *)lookup(parser, &dtd->prefixes, prefixName, sizeof(PREFIX));
const bool prefixNameUsed = prefix && prefix->name == prefixName; if (prefixNameUsed) poolFinish(&dtd->pool); else poolDiscard(&dtd->pool);
if (! prefix) return XML_FALSE;
poolDiscard(&parser->m_tempPool); } for (context = s + 1; *context != CONTEXT_SEP && *context != XML_T('\0');Expand Down
Expand Up
@@ -8036,6 +8062,23 @@ poolCopyString(STRING_POOL *pool, const XML_Char *s) {
return s;
}
// A version of `poolCopyString` that does not call `poolFinish` // and reverts any partial advancement upon failure. static const XML_Char *FASTCALL poolCopyStringNoFinish(STRING_POOL *pool, const XML_Char *s) { const XML_Char *const original = s; do { if (! poolAppendChar(pool, *s)) { // Revert any previously successful advancement const ptrdiff_t advancedBy = s - original; if (advancedBy > 0) pool->ptr -= advancedBy; return NULL; } } while (*s++); return pool->start; }
static const XML_Char * poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n) { if (! pool->ptr && ! poolGrow(pool)) {Expand Down
start = next; } }
const char *next; const char *next = entityTextPtr;
/* Nothing to tokenize. */ if (entityTextPtr >= entityTextEnd) { result = XML_ERROR_NONE; goto endEntityValue; }
for (;;) { next = entityTextPtr; /* XmlEntityValueTok doesn't always set the last arg */
prefix = (PREFIX *)lookup(parser, &dtd->prefixes, prefixName, sizeof(PREFIX));
const bool prefixNameUsed = prefix && prefix->name == prefixName; if (prefixNameUsed) poolFinish(&dtd->pool); else poolDiscard(&dtd->pool);
if (! prefix) return XML_FALSE;
poolDiscard(&parser->m_tempPool); } for (context = s + 1; *context != CONTEXT_SEP && *context != XML_T('\0');
// A version of `poolCopyString` that does not call `poolFinish` // and reverts any partial advancement upon failure. static const XML_Char *FASTCALL poolCopyStringNoFinish(STRING_POOL *pool, const XML_Char *s) { const XML_Char *const original = s; do { if (! poolAppendChar(pool, *s)) { // Revert any previously successful advancement const ptrdiff_t advancedBy = s - original; if (advancedBy > 0) pool->ptr -= advancedBy; return NULL; } } while (*s++); return pool->start; }
static const XML_Char * poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n) { if (! pool->ptr && ! poolGrow(pool)) {