diff --git a/include/libxml/parser.h b/include/libxml/parser.h
index 47fbec0..ae13d8f 100644
--- a/include/libxml/parser.h
+++ b/include/libxml/parser.h
@@ -1111,7 +1111,8 @@ typedef enum {
     XML_PARSE_HUGE	 = 1<<19,/* relax any hardcoded limit from the parser */
     XML_PARSE_OLDSAX	 = 1<<20,/* parse using SAX2 interface before 2.7.0 */
     XML_PARSE_IGNORE_ENC= 1<<21,/* ignore internal document encoding hint */
-    XML_PARSE_BIG_LINES = 1<<22 /* Store big lines numbers in text PSVI field */
+    XML_PARSE_BIG_LINES = 1<<22,/* Store big lines numbers in text PSVI field */
+    XML_PARSE_CHECK_ENT = 1<<23 /* force non-linear entity expansion check */
 } xmlParserOption;

 XMLPUBFUN void XMLCALL
diff --git a/parser.c b/parser.c
index 53a6b7f..5d4affb 100644
--- a/parser.c
+++ b/parser.c
@@ -128,7 +128,8 @@ xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size,
 {
     size_t consumed = 0;

-    if ((ctxt == NULL) || (ctxt->options & XML_PARSE_HUGE))
+    if ((ctxt == NULL) || ((ctxt->options & XML_PARSE_HUGE) != 0 &&
+			    (ctxt->options & XML_PARSE_CHECKENT) == 0)
	 return (0);
     if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP)
	 return (1);
