11_nested_entities.patch (1413B)
1 diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c 2 --- a/expat/lib/xmlparse.c 3 +++ b/expat/lib/xmlparse.c 4 @@ -6085,7 +6085,29 @@ processInternalEntity(XML_Parser parser, 5 entityTrackingOnClose(parser, entity, __LINE__); 6 #endif /* XML_GE == 1 */ 7 entity->open = XML_FALSE; 8 +/* BEGIN MOZILLA CHANGE (Bug 569229 - Deal with parser interruption from nested entities) */ 9 +#if 0 10 parser->m_openInternalEntities = openEntity->next; 11 +#else 12 + if (parser->m_openInternalEntities == openEntity) { 13 + parser->m_openInternalEntities = openEntity->next; 14 + } 15 + else { 16 + /* openEntity should be closed, but it contains an inner entity that is 17 + still open. Remove openEntity from the m_openInternalEntities linked 18 + list by looking for the inner entity in the list that links to 19 + openEntity and fixing up its 'next' member 20 + */ 21 + OPEN_INTERNAL_ENTITY *innerOpenEntity = parser->m_openInternalEntities; 22 + do { 23 + if (innerOpenEntity->next == openEntity) { 24 + innerOpenEntity->next = openEntity->next; 25 + break; 26 + } 27 + } while ((innerOpenEntity = innerOpenEntity->next)); 28 + } 29 +#endif 30 +/* END MOZILLA CHANGE */ 31 /* put openEntity back in list of free instances */ 32 openEntity->next = parser->m_freeInternalEntities; 33 parser->m_freeInternalEntities = openEntity;