mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-12 16:58:16 +03:00
Only warn on invalid redeclarations of predefined entities
Downgrade the error message to a warning since the error was ignored, anyway. Also print the name of redeclared entity. For a proper fix that also shows filename and line number of the invalid redeclaration, we'd have to - pass the parser context to the entity functions somehow, or - make these functions return distinct error codes. Partial fix for #308.
This commit is contained in:
parent
e03590c9ad
commit
ce0871e15c
21
entities.c
21
entities.c
@ -94,6 +94,23 @@ xmlEntitiesErr(xmlParserErrors code, const char *msg)
|
|||||||
__xmlSimpleError(XML_FROM_TREE, code, NULL, msg, NULL);
|
__xmlSimpleError(XML_FROM_TREE, code, NULL, msg, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlEntitiesWarn:
|
||||||
|
* @code: the error code
|
||||||
|
* @msg: the message
|
||||||
|
*
|
||||||
|
* Handle an out of memory condition
|
||||||
|
*/
|
||||||
|
static void LIBXML_ATTR_FORMAT(2,0)
|
||||||
|
xmlEntitiesWarn(xmlParserErrors code, const char *msg, const xmlChar *str1)
|
||||||
|
{
|
||||||
|
__xmlRaiseError(NULL, NULL, NULL,
|
||||||
|
NULL, NULL, XML_FROM_TREE, code,
|
||||||
|
XML_ERR_WARNING, NULL, 0,
|
||||||
|
(const char *)str1, NULL, NULL, 0, 0,
|
||||||
|
msg, (const char *)str1, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* xmlFreeEntity : clean-up an entity record.
|
* xmlFreeEntity : clean-up an entity record.
|
||||||
*/
|
*/
|
||||||
@ -255,9 +272,9 @@ xmlAddEntity(xmlDtdPtr dtd, const xmlChar *name, int type,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
xmlEntitiesErr(XML_ERR_ENTITY_PROCESSING,
|
xmlEntitiesWarn(XML_ERR_ENTITY_PROCESSING,
|
||||||
"xmlAddEntity: invalid redeclaration of predefined"
|
"xmlAddEntity: invalid redeclaration of predefined"
|
||||||
" entity");
|
" entity '%s'", name);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
result/errors/ent_redecl.xml
Normal file
3
result/errors/ent_redecl.xml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE doc>
|
||||||
|
<doc/>
|
1
result/errors/ent_redecl.xml.ent
Normal file
1
result/errors/ent_redecl.xml.ent
Normal file
@ -0,0 +1 @@
|
|||||||
|
warning : xmlAddEntity: invalid redeclaration of predefined entity 'lt'
|
1
result/errors/ent_redecl.xml.err
Normal file
1
result/errors/ent_redecl.xml.err
Normal file
@ -0,0 +1 @@
|
|||||||
|
warning : xmlAddEntity: invalid redeclaration of predefined entity 'lt'
|
1
result/errors/ent_redecl.xml.str
Normal file
1
result/errors/ent_redecl.xml.str
Normal file
@ -0,0 +1 @@
|
|||||||
|
warning : xmlAddEntity: invalid redeclaration of predefined entity 'lt'
|
4
test/errors/ent_redecl.xml
Normal file
4
test/errors/ent_redecl.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<!DOCTYPE doc [
|
||||||
|
<!ENTITY lt '<'>
|
||||||
|
]>
|
||||||
|
<doc/>
|
Loading…
x
Reference in New Issue
Block a user