Diff for /embedaddon/libxml2/SAX2.c between versions 1.1.1.2 and 1.1.1.3

version 1.1.1.2, 2013/07/22 01:22:18 version 1.1.1.3, 2014/06/15 19:53:28
Line 45 Line 45
  *> values "system" and "public".  I have made the default be "system" to   *> values "system" and "public".  I have made the default be "system" to
  *> match yours.   *> match yours.
  */   */
#define TODO                                                            \#define TODO                                                            \
     xmlGenericError(xmlGenericErrorContext,                             \      xmlGenericError(xmlGenericErrorContext,                             \
             "Unimplemented block at %s:%d\n",                           \              "Unimplemented block at %s:%d\n",                           \
             __FILE__, __LINE__);              __FILE__, __LINE__);
Line 57 Line 57
  */   */
 static void  static void
 xmlSAX2ErrMemory(xmlParserCtxtPtr ctxt, const char *msg) {  xmlSAX2ErrMemory(xmlParserCtxtPtr ctxt, const char *msg) {
       xmlStructuredErrorFunc schannel = NULL;
       const char *str1 = "out of memory\n";
   
     if (ctxt != NULL) {      if (ctxt != NULL) {
         if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))  
             ctxt->sax->error(ctxt->userData, "%s: out of memory\n", msg);  
         ctxt->errNo = XML_ERR_NO_MEMORY;          ctxt->errNo = XML_ERR_NO_MEMORY;
           if ((ctxt->sax != NULL) && (ctxt->sax->initialized == XML_SAX2_MAGIC))
               schannel = ctxt->sax->serror;
           __xmlRaiseError(schannel,
                           ctxt->vctxt.error, ctxt->vctxt.userData,
                           ctxt, NULL, XML_FROM_PARSER, XML_ERR_NO_MEMORY,
                           XML_ERR_ERROR, NULL, 0, (const char *) str1,
                           NULL, NULL, 0, 0,
                           msg, (const char *) str1, NULL);
           ctxt->errNo = XML_ERR_NO_MEMORY;
         ctxt->instate = XML_PARSER_EOF;          ctxt->instate = XML_PARSER_EOF;
         ctxt->disableSAX = 1;          ctxt->disableSAX = 1;
       } else {
           __xmlRaiseError(schannel,
                           NULL, NULL,
                           ctxt, NULL, XML_FROM_PARSER, XML_ERR_NO_MEMORY,
                           XML_ERR_ERROR, NULL, 0, (const char *) str1,
                           NULL, NULL, 0, 0,
                           msg, (const char *) str1, NULL);
     }      }
 }  }
   
Line 126  xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors  Line 143  xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors 
     if (ctxt != NULL)      if (ctxt != NULL)
         ctxt->errNo = error;          ctxt->errNo = error;
     __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,      __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
                    XML_ERR_FATAL, NULL, 0,                     XML_ERR_FATAL, NULL, 0,
                     (const char *) str1, (const char *) str2,                      (const char *) str1, (const char *) str2,
                     NULL, 0, 0, msg, str1, str2);                      NULL, 0, 0, msg, str1, str2);
     if (ctxt != NULL) {      if (ctxt != NULL) {
Line 157  xmlWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors erro Line 174  xmlWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors erro
     if (ctxt != NULL)      if (ctxt != NULL)
         ctxt->errNo = error;          ctxt->errNo = error;
     __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,      __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
                    XML_ERR_WARNING, NULL, 0,                     XML_ERR_WARNING, NULL, 0,
                     (const char *) str1, NULL,                      (const char *) str1, NULL,
                     NULL, 0, 0, msg, str1);                      NULL, 0, 0, msg, str1);
 }  }
Line 182  xmlNsErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors err Line 199  xmlNsErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors err
     if (ctxt != NULL)      if (ctxt != NULL)
         ctxt->errNo = error;          ctxt->errNo = error;
     __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error,      __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error,
                    XML_ERR_ERROR, NULL, 0,                     XML_ERR_ERROR, NULL, 0,
                     (const char *) str1, (const char *) str2,                      (const char *) str1, (const char *) str2,
                     NULL, 0, 0, msg, str1, str2);                      NULL, 0, 0, msg, str1, str2);
 }  }
Line 206  xmlNsWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors er Line 223  xmlNsWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors er
     if (ctxt != NULL)      if (ctxt != NULL)
         ctxt->errNo = error;          ctxt->errNo = error;
     __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error,      __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error,
                    XML_ERR_WARNING, NULL, 0,                     XML_ERR_WARNING, NULL, 0,
                     (const char *) str1, (const char *) str2,                      (const char *) str1, (const char *) str2,
                     NULL, 0, 0, msg, str1, str2);                      NULL, 0, 0, msg, str1, str2);
 }  }
Line 240  xmlSAX2GetSystemId(void *ctx) Line 257  xmlSAX2GetSystemId(void *ctx)
 {  {
     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;      xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
     if ((ctx == NULL) || (ctxt->input == NULL)) return(NULL);      if ((ctx == NULL) || (ctxt->input == NULL)) return(NULL);
    return((const xmlChar *) ctxt->input->filename);     return((const xmlChar *) ctxt->input->filename);
 }  }
   
 /**  /**
Line 355  xmlSAX2InternalSubset(void *ctx, const xmlChar *name, Line 372  xmlSAX2InternalSubset(void *ctx, const xmlChar *name,
         xmlFreeDtd(dtd);          xmlFreeDtd(dtd);
         ctxt->myDoc->intSubset = NULL;          ctxt->myDoc->intSubset = NULL;
     }      }
    ctxt->myDoc->intSubset =     ctxt->myDoc->intSubset =
         xmlCreateIntSubset(ctxt->myDoc, name, ExternalID, SystemID);          xmlCreateIntSubset(ctxt->myDoc, name, ExternalID, SystemID);
     if (ctxt->myDoc->intSubset == NULL)      if (ctxt->myDoc->intSubset == NULL)
         xmlSAX2ErrMemory(ctxt, "xmlSAX2InternalSubset");          xmlSAX2ErrMemory(ctxt, "xmlSAX2InternalSubset");
Line 394  xmlSAX2ExternalSubset(void *ctx, const xmlChar *name, Line 411  xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
         xmlParserInputPtr input = NULL;          xmlParserInputPtr input = NULL;
         xmlCharEncoding enc;          xmlCharEncoding enc;
         int oldcharset;          int oldcharset;
           const xmlChar *oldencoding;
   
         /*          /*
          * Ask the Entity resolver to load the damn thing           * Ask the Entity resolver to load the damn thing
Line 415  xmlSAX2ExternalSubset(void *ctx, const xmlChar *name, Line 433  xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
         oldinputMax = ctxt->inputMax;          oldinputMax = ctxt->inputMax;
         oldinputTab = ctxt->inputTab;          oldinputTab = ctxt->inputTab;
         oldcharset = ctxt->charset;          oldcharset = ctxt->charset;
           oldencoding = ctxt->encoding;
           ctxt->encoding = NULL;
   
         ctxt->inputTab = (xmlParserInputPtr *)          ctxt->inputTab = (xmlParserInputPtr *)
                          xmlMalloc(5 * sizeof(xmlParserInputPtr));                           xmlMalloc(5 * sizeof(xmlParserInputPtr));
Line 425  xmlSAX2ExternalSubset(void *ctx, const xmlChar *name, Line 445  xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
             ctxt->inputMax = oldinputMax;              ctxt->inputMax = oldinputMax;
             ctxt->inputTab = oldinputTab;              ctxt->inputTab = oldinputTab;
             ctxt->charset = oldcharset;              ctxt->charset = oldcharset;
               ctxt->encoding = oldencoding;
             return;              return;
         }          }
         ctxt->inputNr = 0;          ctxt->inputNr = 0;
Line 470  xmlSAX2ExternalSubset(void *ctx, const xmlChar *name, Line 491  xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
         ctxt->inputMax = oldinputMax;          ctxt->inputMax = oldinputMax;
         ctxt->inputTab = oldinputTab;          ctxt->inputTab = oldinputTab;
         ctxt->charset = oldcharset;          ctxt->charset = oldcharset;
           if ((ctxt->encoding != NULL) &&
               ((ctxt->dict == NULL) ||
                (!xmlDictOwns(ctxt->dict, ctxt->encoding))))
               xmlFree((xmlChar *) ctxt->encoding);
           ctxt->encoding = oldencoding;
         /* ctxt->wellFormed = oldwellFormed; */          /* ctxt->wellFormed = oldwellFormed; */
     }      }
 }  }
Line 574  xmlSAX2GetEntity(void *ctx, const xmlChar *name) Line 600  xmlSAX2GetEntity(void *ctx, const xmlChar *name)
          * parse the external entity           * parse the external entity
          */           */
         xmlNodePtr children;          xmlNodePtr children;
           unsigned long oldnbent = ctxt->nbentities;
   
         val = xmlParseCtxtExternalEntity(ctxt, ret->URI,          val = xmlParseCtxtExternalEntity(ctxt, ret->URI,
                                          ret->ExternalID, &children);                                           ret->ExternalID, &children);
Line 586  xmlSAX2GetEntity(void *ctx, const xmlChar *name) Line 613  xmlSAX2GetEntity(void *ctx, const xmlChar *name)
             return(NULL);              return(NULL);
         }          }
         ret->owner = 1;          ret->owner = 1;
        if (ret->checked == 0)        if (ret->checked == 0) {
            ret->checked = 1;            ret->checked = (ctxt->nbentities - oldnbent + 1) * 2;
             if ((ret->content != NULL) && (xmlStrchr(ret->content, '<')))
                 ret->checked |= 1;
         }
     }      }
     return(ret);      return(ret);
 }  }
Line 621  xmlSAX2GetParameterEntity(void *ctx, const xmlChar *na Line 651  xmlSAX2GetParameterEntity(void *ctx, const xmlChar *na
 /**  /**
  * xmlSAX2EntityDecl:   * xmlSAX2EntityDecl:
  * @ctx: the user data (XML parser context)   * @ctx: the user data (XML parser context)
 * @name:  the entity name  * @name:  the entity name
 * @type:  the entity type  * @type:  the entity type
  * @publicId: The public ID of the entity   * @publicId: The public ID of the entity
  * @systemId: The system ID of the entity   * @systemId: The system ID of the entity
  * @content: the entity value (without processing).   * @content: the entity value (without processing).
Line 657  xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int  Line 687  xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int 
                 base = ctxt->input->filename;                  base = ctxt->input->filename;
             if (base == NULL)              if (base == NULL)
                 base = ctxt->directory;                  base = ctxt->directory;
        
             URI = xmlBuildURI(systemId, (const xmlChar *) base);              URI = xmlBuildURI(systemId, (const xmlChar *) base);
             ent->URI = URI;              ent->URI = URI;
         }          }
Line 666  xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int  Line 696  xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int 
                               systemId, content);                                systemId, content);
         if ((ent == NULL) && (ctxt->pedantic) &&          if ((ent == NULL) && (ctxt->pedantic) &&
             (ctxt->sax != NULL) && (ctxt->sax->warning != NULL))              (ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
            ctxt->sax->warning(ctxt->userData,             ctxt->sax->warning(ctxt->userData,
              "Entity(%s) already defined in the external subset\n", name);               "Entity(%s) already defined in the external subset\n", name);
         if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {          if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {
             xmlChar *URI;              xmlChar *URI;
Line 676  xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int  Line 706  xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int 
                 base = ctxt->input->filename;                  base = ctxt->input->filename;
             if (base == NULL)              if (base == NULL)
                 base = ctxt->directory;                  base = ctxt->directory;
        
             URI = xmlBuildURI(systemId, (const xmlChar *) base);              URI = xmlBuildURI(systemId, (const xmlChar *) base);
             ent->URI = URI;              ent->URI = URI;
         }          }
Line 691  xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int  Line 721  xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int 
  * xmlSAX2AttributeDecl:   * xmlSAX2AttributeDecl:
  * @ctx: the user data (XML parser context)   * @ctx: the user data (XML parser context)
  * @elem:  the name of the element   * @elem:  the name of the element
 * @fullname:  the attribute name  * @fullname:  the attribute name
 * @type:  the attribute type  * @type:  the attribute type
  * @def:  the type of default value   * @def:  the type of default value
  * @defaultValue: the attribute default value   * @defaultValue: the attribute default value
  * @tree:  the tree of enumerated value set   * @tree:  the tree of enumerated value set
Line 735  xmlSAX2AttributeDecl(void *ctx, const xmlChar *elem, c Line 765  xmlSAX2AttributeDecl(void *ctx, const xmlChar *elem, c
                (xmlAttributeDefault) def, defaultValue, tree);                 (xmlAttributeDefault) def, defaultValue, tree);
     else if (ctxt->inSubset == 2)      else if (ctxt->inSubset == 2)
         attr = xmlAddAttributeDecl(&ctxt->vctxt, ctxt->myDoc->extSubset, elem,          attr = xmlAddAttributeDecl(&ctxt->vctxt, ctxt->myDoc->extSubset, elem,
           name, prefix, (xmlAttributeType) type,            name, prefix, (xmlAttributeType) type,
            (xmlAttributeDefault) def, defaultValue, tree);             (xmlAttributeDefault) def, defaultValue, tree);
     else {      else {
         xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,          xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
Line 761  xmlSAX2AttributeDecl(void *ctx, const xmlChar *elem, c Line 791  xmlSAX2AttributeDecl(void *ctx, const xmlChar *elem, c
 /**  /**
  * xmlSAX2ElementDecl:   * xmlSAX2ElementDecl:
  * @ctx: the user data (XML parser context)   * @ctx: the user data (XML parser context)
 * @name:  the element name  * @name:  the element name
 * @type:  the element type  * @type:  the element type
  * @content: the element value tree   * @content: the element value tree
  *   *
  * An element definition has been parsed   * An element definition has been parsed
Line 883  xmlSAX2UnparsedEntityDecl(void *ctx, const xmlChar *na Line 913  xmlSAX2UnparsedEntityDecl(void *ctx, const xmlChar *na
                         publicId, systemId, notationName);                          publicId, systemId, notationName);
         if ((ent == NULL) && (ctxt->pedantic) &&          if ((ent == NULL) && (ctxt->pedantic) &&
             (ctxt->sax != NULL) && (ctxt->sax->warning != NULL))              (ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
            ctxt->sax->warning(ctxt->userData,             ctxt->sax->warning(ctxt->userData,
              "Entity(%s) already defined in the internal subset\n", name);               "Entity(%s) already defined in the internal subset\n", name);
         if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {          if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {
             xmlChar *URI;              xmlChar *URI;
Line 893  xmlSAX2UnparsedEntityDecl(void *ctx, const xmlChar *na Line 923  xmlSAX2UnparsedEntityDecl(void *ctx, const xmlChar *na
                 base = ctxt->input->filename;                  base = ctxt->input->filename;
             if (base == NULL)              if (base == NULL)
                 base = ctxt->directory;                  base = ctxt->directory;
        
             URI = xmlBuildURI(systemId, (const xmlChar *) base);              URI = xmlBuildURI(systemId, (const xmlChar *) base);
             ent->URI = URI;              ent->URI = URI;
         }          }
Line 903  xmlSAX2UnparsedEntityDecl(void *ctx, const xmlChar *na Line 933  xmlSAX2UnparsedEntityDecl(void *ctx, const xmlChar *na
                         publicId, systemId, notationName);                          publicId, systemId, notationName);
         if ((ent == NULL) && (ctxt->pedantic) &&          if ((ent == NULL) && (ctxt->pedantic) &&
             (ctxt->sax != NULL) && (ctxt->sax->warning != NULL))              (ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
            ctxt->sax->warning(ctxt->userData,             ctxt->sax->warning(ctxt->userData,
              "Entity(%s) already defined in the external subset\n", name);               "Entity(%s) already defined in the external subset\n", name);
         if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {          if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {
             xmlChar *URI;              xmlChar *URI;
Line 913  xmlSAX2UnparsedEntityDecl(void *ctx, const xmlChar *na Line 943  xmlSAX2UnparsedEntityDecl(void *ctx, const xmlChar *na
                 base = ctxt->input->filename;                  base = ctxt->input->filename;
             if (base == NULL)              if (base == NULL)
                 base = ctxt->directory;                  base = ctxt->directory;
        
             URI = xmlBuildURI(systemId, (const xmlChar *) base);              URI = xmlBuildURI(systemId, (const xmlChar *) base);
             ent->URI = URI;              ent->URI = URI;
         }          }
Line 1157  xmlSAX2AttributeInternal(void *ctx, const xmlChar *ful Line 1187  xmlSAX2AttributeInternal(void *ctx, const xmlChar *ful
             uri = xmlParseURI((const char *)val);              uri = xmlParseURI((const char *)val);
             if (uri == NULL) {              if (uri == NULL) {
                 if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL))                  if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
                    ctxt->sax->warning(ctxt->userData,                     ctxt->sax->warning(ctxt->userData,
                          "xmlns: %s not a valid URI\n", val);                           "xmlns: %s not a valid URI\n", val);
             } else {              } else {
                 if (uri->scheme == NULL) {                  if (uri->scheme == NULL) {
                     if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL))                      if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
                        ctxt->sax->warning(ctxt->userData,                         ctxt->sax->warning(ctxt->userData,
                              "xmlns: URI %s is not absolute\n", val);                               "xmlns: URI %s is not absolute\n", val);
                 }                  }
                 xmlFreeURI(uri);                  xmlFreeURI(uri);
Line 1182  xmlSAX2AttributeInternal(void *ctx, const xmlChar *ful Line 1212  xmlSAX2AttributeInternal(void *ctx, const xmlChar *ful
             ctxt->valid &= xmlValidateOneNamespace(&ctxt->vctxt, ctxt->myDoc,              ctxt->valid &= xmlValidateOneNamespace(&ctxt->vctxt, ctxt->myDoc,
                                            ctxt->node, prefix, nsret, val);                                             ctxt->node, prefix, nsret, val);
 #endif /* LIBXML_VALID_ENABLED */  #endif /* LIBXML_VALID_ENABLED */
        if (name != NULL)         if (name != NULL)
             xmlFree(name);              xmlFree(name);
         if (nval != NULL)          if (nval != NULL)
             xmlFree(nval);              xmlFree(nval);
Line 1204  xmlSAX2AttributeInternal(void *ctx, const xmlChar *ful Line 1234  xmlSAX2AttributeInternal(void *ctx, const xmlChar *ful
             if (val == NULL) {              if (val == NULL) {
                 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");                  xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
                 xmlFree(ns);                  xmlFree(ns);
                if (name != NULL)                 if (name != NULL)
                     xmlFree(name);                      xmlFree(name);
                 return;                  return;
             }              }
Line 1245  xmlSAX2AttributeInternal(void *ctx, const xmlChar *ful Line 1275  xmlSAX2AttributeInternal(void *ctx, const xmlChar *ful
             ctxt->valid &= xmlValidateOneNamespace(&ctxt->vctxt, ctxt->myDoc,              ctxt->valid &= xmlValidateOneNamespace(&ctxt->vctxt, ctxt->myDoc,
                                            ctxt->node, prefix, nsret, value);                                             ctxt->node, prefix, nsret, value);
 #endif /* LIBXML_VALID_ENABLED */  #endif /* LIBXML_VALID_ENABLED */
        if (name != NULL)         if (name != NULL)
             xmlFree(name);              xmlFree(name);
         if (nval != NULL)          if (nval != NULL)
             xmlFree(nval);              xmlFree(nval);
Line 1311  xmlSAX2AttributeInternal(void *ctx, const xmlChar *ful Line 1341  xmlSAX2AttributeInternal(void *ctx, const xmlChar *ful
 #ifdef LIBXML_VALID_ENABLED  #ifdef LIBXML_VALID_ENABLED
     if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed &&      if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed &&
         ctxt->myDoc && ctxt->myDoc->intSubset) {          ctxt->myDoc && ctxt->myDoc->intSubset) {
        
         /*          /*
          * If we don't substitute entities, the validation should be           * If we don't substitute entities, the validation should be
          * done on a value with replaced entities anyway.           * done on a value with replaced entities anyway.
Line 1323  xmlSAX2AttributeInternal(void *ctx, const xmlChar *ful Line 1353  xmlSAX2AttributeInternal(void *ctx, const xmlChar *ful
             val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF,              val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF,
                                           0,0,0);                                            0,0,0);
             ctxt->depth--;              ctxt->depth--;
            
             if (val == NULL)              if (val == NULL)
                 ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,                  ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
                                 ctxt->myDoc, ctxt->node, ret, value);                                  ctxt->myDoc, ctxt->node, ret, value);
Line 1380  xmlSAX2AttributeInternal(void *ctx, const xmlChar *ful Line 1410  xmlSAX2AttributeInternal(void *ctx, const xmlChar *ful
 error:  error:
     if (nval != NULL)      if (nval != NULL)
         xmlFree(nval);          xmlFree(nval);
    if (ns != NULL)     if (ns != NULL)
         xmlFree(ns);          xmlFree(ns);
 }  }
   
Line 1479  process_external_subset: Line 1509  process_external_subset:
                  *  - this is a namespace prefix                   *  - this is a namespace prefix
                  *  - the user required for completion in the tree                   *  - the user required for completion in the tree
                  *    like XSLT                   *    like XSLT
                 *  - there isn't already an attribute definition                  *  - there isn't already an attribute definition
                  *    in the internal subset overriding it.                   *    in the internal subset overriding it.
                  */                   */
                 if (((attr->prefix != NULL) &&                  if (((attr->prefix != NULL) &&
Line 1568  xmlSAX2StartElement(void *ctx, const xmlChar *fullname Line 1598  xmlSAX2StartElement(void *ctx, const xmlChar *fullname
     /*      /*
      * First check on validity:       * First check on validity:
      */       */
    if (ctxt->validate && (ctxt->myDoc->extSubset == NULL) &&     if (ctxt->validate && (ctxt->myDoc->extSubset == NULL) &&
         ((ctxt->myDoc->intSubset == NULL) ||          ((ctxt->myDoc->intSubset == NULL) ||
         ((ctxt->myDoc->intSubset->notations == NULL) &&          ((ctxt->myDoc->intSubset->notations == NULL) &&
           (ctxt->myDoc->intSubset->elements == NULL) &&            (ctxt->myDoc->intSubset->elements == NULL) &&
          (ctxt->myDoc->intSubset->attributes == NULL) &&           (ctxt->myDoc->intSubset->attributes == NULL) &&
           (ctxt->myDoc->intSubset->entities == NULL)))) {            (ctxt->myDoc->intSubset->entities == NULL)))) {
         xmlErrValid(ctxt, XML_ERR_NO_DTD,          xmlErrValid(ctxt, XML_ERR_NO_DTD,
           "Validation failed: no DTD found !", NULL, NULL);            "Validation failed: no DTD found !", NULL, NULL);
         ctxt->validate = 0;          ctxt->validate = 0;
     }      }
          
   
   
     /*      /*
      * Split the full name into a namespace prefix and the tag name       * Split the full name into a namespace prefix and the tag name
      */       */
Line 1766  xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRI Line 1796  xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRI
     else      else
         xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2EndElement(%s)\n", name);          xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2EndElement(%s)\n", name);
 #endif  #endif
    
     /* Capture end position and add node */      /* Capture end position and add node */
     if (cur != NULL && ctxt->record_info) {      if (cur != NULL && ctxt->record_info) {
       ctxt->nodeInfo->end_pos = ctxt->input->cur - ctxt->input->base;        ctxt->nodeInfo->end_pos = ctxt->input->cur - ctxt->input->base;
Line 1783  xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRI Line 1813  xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRI
                                              cur);                                               cur);
 #endif /* LIBXML_VALID_ENABLED */  #endif /* LIBXML_VALID_ENABLED */
   
    
     /*      /*
      * end of parsing of this node.       * end of parsing of this node.
      */       */
Line 1799  xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRI Line 1829  xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRI
  * @ctxt:  the parser context   * @ctxt:  the parser context
  * @str:  the input string   * @str:  the input string
  * @len: the string length   * @len: the string length
  *   
  * Remove the entities from an attribute value  
  *   *
    * Callback for a text node
    *
  * Returns the newly allocated string or NULL if not needed or error   * Returns the newly allocated string or NULL if not needed or error
  */   */
 static xmlNodePtr  static xmlNodePtr
Line 1833  xmlSAX2TextNode(xmlParserCtxtPtr ctxt, const xmlChar * Line 1863  xmlSAX2TextNode(xmlParserCtxtPtr ctxt, const xmlChar *
   
         if ((len < (int) (2 * sizeof(void *))) &&          if ((len < (int) (2 * sizeof(void *))) &&
             (ctxt->options & XML_PARSE_COMPACT)) {              (ctxt->options & XML_PARSE_COMPACT)) {
            /* store the string in the node overrithing properties and nsDef */            /* store the string in the node overriding properties and nsDef */
             xmlChar *tmp = (xmlChar *) &(ret->properties);              xmlChar *tmp = (xmlChar *) &(ret->properties);
             memcpy(tmp, str, len);              memcpy(tmp, str, len);
             tmp[len] = 0;              tmp[len] = 0;
Line 1865  skip: Line 1895  skip:
     } else      } else
         ret->content = (xmlChar *) intern;          ret->content = (xmlChar *) intern;
   
    if (ctxt->input != NULL)    if (ctxt->linenumbers) {
        ret->line = ctxt->input->line;        if (ctxt->input != NULL) {
             if (ctxt->input->line < 65535)
                 ret->line = (short) ctxt->input->line;
             else {
                 ret->line = 65535;
                 if (ctxt->options & XML_PARSE_BIG_LINES)
                     ret->psvi = (void *) (long) ctxt->input->line;
             }
         }
     }
   
     if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))      if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))
         xmlRegisterNodeDefaultValue(ret);          xmlRegisterNodeDefaultValue(ret);
Line 1879  skip: Line 1918  skip:
  * @ctxt:  the parser context   * @ctxt:  the parser context
  * @str:  the input string   * @str:  the input string
  * @len: the string length   * @len: the string length
 *  *
  * Remove the entities from an attribute value   * Remove the entities from an attribute value
  *   *
  * Returns the newly allocated string or NULL if not needed or error   * Returns the newly allocated string or NULL if not needed or error
Line 1945  xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt, Line 1984  xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
         memset(ret, 0, sizeof(xmlAttr));          memset(ret, 0, sizeof(xmlAttr));
         ret->type = XML_ATTRIBUTE_NODE;          ret->type = XML_ATTRIBUTE_NODE;
   
        ret->parent = ctxt->node;         ret->parent = ctxt->node;
         ret->doc = ctxt->myDoc;          ret->doc = ctxt->myDoc;
         ret->ns = namespace;          ret->ns = namespace;
   
Line 1969  xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt, Line 2008  xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
             xmlRegisterNodeDefaultValue((xmlNodePtr)ret);              xmlRegisterNodeDefaultValue((xmlNodePtr)ret);
     } else {      } else {
         if (ctxt->dictNames)          if (ctxt->dictNames)
            ret = xmlNewNsPropEatName(ctxt->node, namespace,             ret = xmlNewNsPropEatName(ctxt->node, namespace,
                                       (xmlChar *) localname, NULL);                                        (xmlChar *) localname, NULL);
         else          else
             ret = xmlNewNsProp(ctxt->node, namespace, localname, NULL);              ret = xmlNewNsProp(ctxt->node, namespace, localname, NULL);
Line 2055  xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt, Line 2094  xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
                     xmlChar *nvalnorm;                      xmlChar *nvalnorm;
                     xmlChar fn[50];                      xmlChar fn[50];
                     xmlChar *fullname;                      xmlChar *fullname;
                    
                     fullname = xmlBuildQName(localname, prefix, fn, 50);                      fullname = xmlBuildQName(localname, prefix, fn, 50);
                     if (fullname != NULL) {                      if (fullname != NULL) {
                         ctxt->vctxt.valid = 1;                          ctxt->vctxt.valid = 1;
Line 2170  xmlSAX2StartElementNs(void *ctx, Line 2209  xmlSAX2StartElementNs(void *ctx,
     /*      /*
      * First check on validity:       * First check on validity:
      */       */
    if (ctxt->validate && (ctxt->myDoc->extSubset == NULL) &&     if (ctxt->validate && (ctxt->myDoc->extSubset == NULL) &&
         ((ctxt->myDoc->intSubset == NULL) ||          ((ctxt->myDoc->intSubset == NULL) ||
         ((ctxt->myDoc->intSubset->notations == NULL) &&          ((ctxt->myDoc->intSubset->notations == NULL) &&
           (ctxt->myDoc->intSubset->elements == NULL) &&            (ctxt->myDoc->intSubset->elements == NULL) &&
          (ctxt->myDoc->intSubset->attributes == NULL) &&           (ctxt->myDoc->intSubset->attributes == NULL) &&
           (ctxt->myDoc->intSubset->entities == NULL)))) {            (ctxt->myDoc->intSubset->entities == NULL)))) {
        xmlErrValid(ctxt, XML_ERR_NO_DTD,        xmlErrValid(ctxt, XML_DTD_NO_DTD,
           "Validation failed: no DTD found !", NULL, NULL);            "Validation failed: no DTD found !", NULL, NULL);
         ctxt->validate = 0;          ctxt->validate = 0;
     }      }
Line 2221  xmlSAX2StartElementNs(void *ctx, Line 2260  xmlSAX2StartElementNs(void *ctx,
             xmlRegisterNodeDefaultValue(ret);              xmlRegisterNodeDefaultValue(ret);
     } else {      } else {
         if (ctxt->dictNames)          if (ctxt->dictNames)
            ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL,             ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL,
                                        (xmlChar *) localname, NULL);                                         (xmlChar *) localname, NULL);
         else if (lname == NULL)          else if (lname == NULL)
             ret = xmlNewDocNode(ctxt->myDoc, NULL, localname, NULL);              ret = xmlNewDocNode(ctxt->myDoc, NULL, localname, NULL);
         else          else
            ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL,             ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL,
                                        (xmlChar *) lname, NULL);                                         (xmlChar *) lname, NULL);
         if (ret == NULL) {          if (ret == NULL) {
             xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");              xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
Line 2431  xmlSAX2EndElementNs(void *ctx, Line 2470  xmlSAX2EndElementNs(void *ctx,
  * @ctx: the user data (XML parser context)   * @ctx: the user data (XML parser context)
  * @name:  The entity name   * @name:  The entity name
  *   *
 * called when an entity xmlSAX2Reference is detected.  * called when an entity xmlSAX2Reference is detected.
  */   */
 void  void
 xmlSAX2Reference(void *ctx, const xmlChar *name)  xmlSAX2Reference(void *ctx, const xmlChar *name)
Line 2536  xmlSAX2Characters(void *ctx, const xmlChar *ch, int le Line 2575  xmlSAX2Characters(void *ctx, const xmlChar *ch, int le
                 xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: huge text node");                  xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: huge text node");
                 return;                  return;
             }              }
            if ((size_t)ctxt->nodelen > SIZE_T_MAX - (size_t)len ||             if ((size_t)ctxt->nodelen > SIZE_T_MAX - (size_t)len ||
                 (size_t)ctxt->nodemem + (size_t)len > SIZE_T_MAX / 2) {                  (size_t)ctxt->nodemem + (size_t)len > SIZE_T_MAX / 2) {
                 xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters overflow prevented");                  xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters overflow prevented");
                 return;                  return;

Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>