Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: third_party/libxml/src/parser.c

Issue 2010803004: Roll libxml to bdec2183f34b37ee89ae1d330c6ad2bb4d76605f (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update README.chromium Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/libxml/src/macos/src/macos_main.c ('k') | third_party/libxml/src/parserInternals.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * parser.c : an XML 1.0 parser, namespaces and validity support are mostly 2 * parser.c : an XML 1.0 parser, namespaces and validity support are mostly
3 * implemented on top of the SAX interfaces 3 * implemented on top of the SAX interfaces
4 * 4 *
5 * References: 5 * References:
6 * The XML specification: 6 * The XML specification:
7 * http://www.w3.org/TR/REC-xml 7 * http://www.w3.org/TR/REC-xml
8 * Original 1.0 version: 8 * Original 1.0 version:
9 * http://www.w3.org/TR/1998/REC-xml-19980210 9 * http://www.w3.org/TR/1998/REC-xml-19980210
10 * XML second edition working draft 10 * XML second edition working draft
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 if ((ctxt == NULL) || (ctxt->options & XML_PARSE_HUGE)) 131 if ((ctxt == NULL) || (ctxt->options & XML_PARSE_HUGE))
132 return (0); 132 return (0);
133 if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP) 133 if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP)
134 return (1); 134 return (1);
135 135
136 /* 136 /*
137 * This may look absurd but is needed to detect 137 * This may look absurd but is needed to detect
138 * entities problems 138 * entities problems
139 */ 139 */
140 if ((ent != NULL) && (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) && 140 if ((ent != NULL) && (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
141 » (ent->content != NULL) && (ent->checked == 0)) { 141 » (ent->content != NULL) && (ent->checked == 0) &&
142 » (ctxt->errNo != XML_ERR_ENTITY_LOOP)) {
142 unsigned long oldnbent = ctxt->nbentities; 143 unsigned long oldnbent = ctxt->nbentities;
143 xmlChar *rep; 144 xmlChar *rep;
144 145
145 ent->checked = 1; 146 ent->checked = 1;
146 147
148 ++ctxt->depth;
147 rep = xmlStringDecodeEntities(ctxt, ent->content, 149 rep = xmlStringDecodeEntities(ctxt, ent->content,
148 XML_SUBSTITUTE_REF, 0, 0, 0); 150 XML_SUBSTITUTE_REF, 0, 0, 0);
151 --ctxt->depth;
152 if (ctxt->errNo == XML_ERR_ENTITY_LOOP) {
153 ent->content[0] = 0;
154 }
149 155
150 ent->checked = (ctxt->nbentities - oldnbent + 1) * 2; 156 ent->checked = (ctxt->nbentities - oldnbent + 1) * 2;
151 if (rep != NULL) { 157 if (rep != NULL) {
152 if (xmlStrchr(rep, '<')) 158 if (xmlStrchr(rep, '<'))
153 ent->checked |= 1; 159 ent->checked |= 1;
154 xmlFree(rep); 160 xmlFree(rep);
155 rep = NULL; 161 rep = NULL;
156 } 162 }
157 } 163 }
158 if (replacement != 0) { 164 if (replacement != 0) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 * @ctxt: an XML parser context 343 * @ctxt: an XML parser context
338 * @error: the error number 344 * @error: the error number
339 * @extra: extra information string 345 * @extra: extra information string
340 * 346 *
341 * Handle a fatal parser error, i.e. violating Well-Formedness constraints 347 * Handle a fatal parser error, i.e. violating Well-Formedness constraints
342 */ 348 */
343 static void 349 static void
344 xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info) 350 xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
345 { 351 {
346 const char *errmsg; 352 const char *errmsg;
347 char errstr[129] = "";
348 353
349 if ((ctxt != NULL) && (ctxt->disableSAX != 0) && 354 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
350 (ctxt->instate == XML_PARSER_EOF)) 355 (ctxt->instate == XML_PARSER_EOF))
351 return; 356 return;
352 switch (error) { 357 switch (error) {
353 case XML_ERR_INVALID_HEX_CHARREF: 358 case XML_ERR_INVALID_HEX_CHARREF:
354 errmsg = "CharRef: invalid hexadecimal value"; 359 errmsg = "CharRef: invalid hexadecimal value";
355 break; 360 break;
356 case XML_ERR_INVALID_DEC_CHARREF: 361 case XML_ERR_INVALID_DEC_CHARREF:
357 errmsg = "CharRef: invalid decimal value"; 362 errmsg = "CharRef: invalid decimal value";
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 errmsg = "Name too long use XML_PARSE_HUGE option"; 529 errmsg = "Name too long use XML_PARSE_HUGE option";
525 break; 530 break;
526 #if 0 531 #if 0
527 case: 532 case:
528 errmsg = ""; 533 errmsg = "";
529 break; 534 break;
530 #endif 535 #endif
531 default: 536 default:
532 errmsg = "Unregistered error message"; 537 errmsg = "Unregistered error message";
533 } 538 }
534 if (info == NULL)
535 snprintf(errstr, 128, "%s\n", errmsg);
536 else
537 snprintf(errstr, 128, "%s: %%s\n", errmsg);
538 if (ctxt != NULL) 539 if (ctxt != NULL)
539 ctxt->errNo = error; 540 ctxt->errNo = error;
540 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error, 541 if (info == NULL) {
541 XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, &errstr[0], 542 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
542 info); 543 XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, "%s\n",
544 errmsg);
545 } else {
546 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
547 XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, "%s: %s\ n",
548 errmsg, info);
549 }
543 if (ctxt != NULL) { 550 if (ctxt != NULL) {
544 ctxt->wellFormed = 0; 551 ctxt->wellFormed = 0;
545 if (ctxt->recovery == 0) 552 if (ctxt->recovery == 0)
546 ctxt->disableSAX = 1; 553 ctxt->disableSAX = 1;
547 } 554 }
548 } 555 }
549 556
550 /** 557 /**
551 * xmlFatalErrMsg: 558 * xmlFatalErrMsg:
552 * @ctxt: an XML parser context 559 * @ctxt: an XML parser context
553 * @error: the error number 560 * @error: the error number
554 * @msg: the error message 561 * @msg: the error message
555 * 562 *
556 * Handle a fatal parser error, i.e. violating Well-Formedness constraints 563 * Handle a fatal parser error, i.e. violating Well-Formedness constraints
557 */ 564 */
558 static void 565 static void LIBXML_ATTR_FORMAT(3,0)
559 xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, 566 xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
560 const char *msg) 567 const char *msg)
561 { 568 {
562 if ((ctxt != NULL) && (ctxt->disableSAX != 0) && 569 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
563 (ctxt->instate == XML_PARSER_EOF)) 570 (ctxt->instate == XML_PARSER_EOF))
564 return; 571 return;
565 if (ctxt != NULL) 572 if (ctxt != NULL)
566 ctxt->errNo = error; 573 ctxt->errNo = error;
567 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error, 574 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
568 XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, "%s", msg); 575 XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, "%s", msg);
569 if (ctxt != NULL) { 576 if (ctxt != NULL) {
570 ctxt->wellFormed = 0; 577 ctxt->wellFormed = 0;
571 if (ctxt->recovery == 0) 578 if (ctxt->recovery == 0)
572 ctxt->disableSAX = 1; 579 ctxt->disableSAX = 1;
573 } 580 }
574 } 581 }
575 582
576 /** 583 /**
577 * xmlWarningMsg: 584 * xmlWarningMsg:
578 * @ctxt: an XML parser context 585 * @ctxt: an XML parser context
579 * @error: the error number 586 * @error: the error number
580 * @msg: the error message 587 * @msg: the error message
581 * @str1: extra data 588 * @str1: extra data
582 * @str2: extra data 589 * @str2: extra data
583 * 590 *
584 * Handle a warning. 591 * Handle a warning.
585 */ 592 */
586 static void 593 static void LIBXML_ATTR_FORMAT(3,0)
587 xmlWarningMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, 594 xmlWarningMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
588 const char *msg, const xmlChar *str1, const xmlChar *str2) 595 const char *msg, const xmlChar *str1, const xmlChar *str2)
589 { 596 {
590 xmlStructuredErrorFunc schannel = NULL; 597 xmlStructuredErrorFunc schannel = NULL;
591 598
592 if ((ctxt != NULL) && (ctxt->disableSAX != 0) && 599 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
593 (ctxt->instate == XML_PARSER_EOF)) 600 (ctxt->instate == XML_PARSER_EOF))
594 return; 601 return;
595 if ((ctxt != NULL) && (ctxt->sax != NULL) && 602 if ((ctxt != NULL) && (ctxt->sax != NULL) &&
596 (ctxt->sax->initialized == XML_SAX2_MAGIC)) 603 (ctxt->sax->initialized == XML_SAX2_MAGIC))
(...skipping 17 matching lines...) Expand all
614 621
615 /** 622 /**
616 * xmlValidityError: 623 * xmlValidityError:
617 * @ctxt: an XML parser context 624 * @ctxt: an XML parser context
618 * @error: the error number 625 * @error: the error number
619 * @msg: the error message 626 * @msg: the error message
620 * @str1: extra data 627 * @str1: extra data
621 * 628 *
622 * Handle a validity error. 629 * Handle a validity error.
623 */ 630 */
624 static void 631 static void LIBXML_ATTR_FORMAT(3,0)
625 xmlValidityError(xmlParserCtxtPtr ctxt, xmlParserErrors error, 632 xmlValidityError(xmlParserCtxtPtr ctxt, xmlParserErrors error,
626 const char *msg, const xmlChar *str1, const xmlChar *str2) 633 const char *msg, const xmlChar *str1, const xmlChar *str2)
627 { 634 {
628 xmlStructuredErrorFunc schannel = NULL; 635 xmlStructuredErrorFunc schannel = NULL;
629 636
630 if ((ctxt != NULL) && (ctxt->disableSAX != 0) && 637 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
631 (ctxt->instate == XML_PARSER_EOF)) 638 (ctxt->instate == XML_PARSER_EOF))
632 return; 639 return;
633 if (ctxt != NULL) { 640 if (ctxt != NULL) {
634 ctxt->errNo = error; 641 ctxt->errNo = error;
(...skipping 19 matching lines...) Expand all
654 661
655 /** 662 /**
656 * xmlFatalErrMsgInt: 663 * xmlFatalErrMsgInt:
657 * @ctxt: an XML parser context 664 * @ctxt: an XML parser context
658 * @error: the error number 665 * @error: the error number
659 * @msg: the error message 666 * @msg: the error message
660 * @val: an integer value 667 * @val: an integer value
661 * 668 *
662 * Handle a fatal parser error, i.e. violating Well-Formedness constraints 669 * Handle a fatal parser error, i.e. violating Well-Formedness constraints
663 */ 670 */
664 static void 671 static void LIBXML_ATTR_FORMAT(3,0)
665 xmlFatalErrMsgInt(xmlParserCtxtPtr ctxt, xmlParserErrors error, 672 xmlFatalErrMsgInt(xmlParserCtxtPtr ctxt, xmlParserErrors error,
666 const char *msg, int val) 673 const char *msg, int val)
667 { 674 {
668 if ((ctxt != NULL) && (ctxt->disableSAX != 0) && 675 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
669 (ctxt->instate == XML_PARSER_EOF)) 676 (ctxt->instate == XML_PARSER_EOF))
670 return; 677 return;
671 if (ctxt != NULL) 678 if (ctxt != NULL)
672 ctxt->errNo = error; 679 ctxt->errNo = error;
673 __xmlRaiseError(NULL, NULL, NULL, 680 __xmlRaiseError(NULL, NULL, NULL,
674 ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_FATAL, 681 ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_FATAL,
675 NULL, 0, NULL, NULL, NULL, val, 0, msg, val); 682 NULL, 0, NULL, NULL, NULL, val, 0, msg, val);
676 if (ctxt != NULL) { 683 if (ctxt != NULL) {
677 ctxt->wellFormed = 0; 684 ctxt->wellFormed = 0;
678 if (ctxt->recovery == 0) 685 if (ctxt->recovery == 0)
679 ctxt->disableSAX = 1; 686 ctxt->disableSAX = 1;
680 } 687 }
681 } 688 }
682 689
683 /** 690 /**
684 * xmlFatalErrMsgStrIntStr: 691 * xmlFatalErrMsgStrIntStr:
685 * @ctxt: an XML parser context 692 * @ctxt: an XML parser context
686 * @error: the error number 693 * @error: the error number
687 * @msg: the error message 694 * @msg: the error message
688 * @str1: an string info 695 * @str1: an string info
689 * @val: an integer value 696 * @val: an integer value
690 * @str2: an string info 697 * @str2: an string info
691 * 698 *
692 * Handle a fatal parser error, i.e. violating Well-Formedness constraints 699 * Handle a fatal parser error, i.e. violating Well-Formedness constraints
693 */ 700 */
694 static void 701 static void LIBXML_ATTR_FORMAT(3,0)
695 xmlFatalErrMsgStrIntStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, 702 xmlFatalErrMsgStrIntStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
696 const char *msg, const xmlChar *str1, int val, 703 const char *msg, const xmlChar *str1, int val,
697 const xmlChar *str2) 704 const xmlChar *str2)
698 { 705 {
699 if ((ctxt != NULL) && (ctxt->disableSAX != 0) && 706 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
700 (ctxt->instate == XML_PARSER_EOF)) 707 (ctxt->instate == XML_PARSER_EOF))
701 return; 708 return;
702 if (ctxt != NULL) 709 if (ctxt != NULL)
703 ctxt->errNo = error; 710 ctxt->errNo = error;
704 __xmlRaiseError(NULL, NULL, NULL, 711 __xmlRaiseError(NULL, NULL, NULL,
705 ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_FATAL, 712 ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_FATAL,
706 NULL, 0, (const char *) str1, (const char *) str2, 713 NULL, 0, (const char *) str1, (const char *) str2,
707 NULL, val, 0, msg, str1, val, str2); 714 NULL, val, 0, msg, str1, val, str2);
708 if (ctxt != NULL) { 715 if (ctxt != NULL) {
709 ctxt->wellFormed = 0; 716 ctxt->wellFormed = 0;
710 if (ctxt->recovery == 0) 717 if (ctxt->recovery == 0)
711 ctxt->disableSAX = 1; 718 ctxt->disableSAX = 1;
712 } 719 }
713 } 720 }
714 721
715 /** 722 /**
716 * xmlFatalErrMsgStr: 723 * xmlFatalErrMsgStr:
717 * @ctxt: an XML parser context 724 * @ctxt: an XML parser context
718 * @error: the error number 725 * @error: the error number
719 * @msg: the error message 726 * @msg: the error message
720 * @val: a string value 727 * @val: a string value
721 * 728 *
722 * Handle a fatal parser error, i.e. violating Well-Formedness constraints 729 * Handle a fatal parser error, i.e. violating Well-Formedness constraints
723 */ 730 */
724 static void 731 static void LIBXML_ATTR_FORMAT(3,0)
725 xmlFatalErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, 732 xmlFatalErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
726 const char *msg, const xmlChar * val) 733 const char *msg, const xmlChar * val)
727 { 734 {
728 if ((ctxt != NULL) && (ctxt->disableSAX != 0) && 735 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
729 (ctxt->instate == XML_PARSER_EOF)) 736 (ctxt->instate == XML_PARSER_EOF))
730 return; 737 return;
731 if (ctxt != NULL) 738 if (ctxt != NULL)
732 ctxt->errNo = error; 739 ctxt->errNo = error;
733 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, 740 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL,
734 XML_FROM_PARSER, error, XML_ERR_FATAL, 741 XML_FROM_PARSER, error, XML_ERR_FATAL,
735 NULL, 0, (const char *) val, NULL, NULL, 0, 0, msg, 742 NULL, 0, (const char *) val, NULL, NULL, 0, 0, msg,
736 val); 743 val);
737 if (ctxt != NULL) { 744 if (ctxt != NULL) {
738 ctxt->wellFormed = 0; 745 ctxt->wellFormed = 0;
739 if (ctxt->recovery == 0) 746 if (ctxt->recovery == 0)
740 ctxt->disableSAX = 1; 747 ctxt->disableSAX = 1;
741 } 748 }
742 } 749 }
743 750
744 /** 751 /**
745 * xmlErrMsgStr: 752 * xmlErrMsgStr:
746 * @ctxt: an XML parser context 753 * @ctxt: an XML parser context
747 * @error: the error number 754 * @error: the error number
748 * @msg: the error message 755 * @msg: the error message
749 * @val: a string value 756 * @val: a string value
750 * 757 *
751 * Handle a non fatal parser error 758 * Handle a non fatal parser error
752 */ 759 */
753 static void 760 static void LIBXML_ATTR_FORMAT(3,0)
754 xmlErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, 761 xmlErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
755 const char *msg, const xmlChar * val) 762 const char *msg, const xmlChar * val)
756 { 763 {
757 if ((ctxt != NULL) && (ctxt->disableSAX != 0) && 764 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
758 (ctxt->instate == XML_PARSER_EOF)) 765 (ctxt->instate == XML_PARSER_EOF))
759 return; 766 return;
760 if (ctxt != NULL) 767 if (ctxt != NULL)
761 ctxt->errNo = error; 768 ctxt->errNo = error;
762 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, 769 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL,
763 XML_FROM_PARSER, error, XML_ERR_ERROR, 770 XML_FROM_PARSER, error, XML_ERR_ERROR,
764 NULL, 0, (const char *) val, NULL, NULL, 0, 0, msg, 771 NULL, 0, (const char *) val, NULL, NULL, 0, 0, msg,
765 val); 772 val);
766 } 773 }
767 774
768 /** 775 /**
769 * xmlNsErr: 776 * xmlNsErr:
770 * @ctxt: an XML parser context 777 * @ctxt: an XML parser context
771 * @error: the error number 778 * @error: the error number
772 * @msg: the message 779 * @msg: the message
773 * @info1: extra information string 780 * @info1: extra information string
774 * @info2: extra information string 781 * @info2: extra information string
775 * 782 *
776 * Handle a fatal parser error, i.e. violating Well-Formedness constraints 783 * Handle a fatal parser error, i.e. violating Well-Formedness constraints
777 */ 784 */
778 static void 785 static void LIBXML_ATTR_FORMAT(3,0)
779 xmlNsErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, 786 xmlNsErr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
780 const char *msg, 787 const char *msg,
781 const xmlChar * info1, const xmlChar * info2, 788 const xmlChar * info1, const xmlChar * info2,
782 const xmlChar * info3) 789 const xmlChar * info3)
783 { 790 {
784 if ((ctxt != NULL) && (ctxt->disableSAX != 0) && 791 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
785 (ctxt->instate == XML_PARSER_EOF)) 792 (ctxt->instate == XML_PARSER_EOF))
786 return; 793 return;
787 if (ctxt != NULL) 794 if (ctxt != NULL)
788 ctxt->errNo = error; 795 ctxt->errNo = error;
789 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error, 796 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error,
790 XML_ERR_ERROR, NULL, 0, (const char *) info1, 797 XML_ERR_ERROR, NULL, 0, (const char *) info1,
791 (const char *) info2, (const char *) info3, 0, 0, msg, 798 (const char *) info2, (const char *) info3, 0, 0, msg,
792 info1, info2, info3); 799 info1, info2, info3);
793 if (ctxt != NULL) 800 if (ctxt != NULL)
794 ctxt->nsWellFormed = 0; 801 ctxt->nsWellFormed = 0;
795 } 802 }
796 803
797 /** 804 /**
798 * xmlNsWarn 805 * xmlNsWarn
799 * @ctxt: an XML parser context 806 * @ctxt: an XML parser context
800 * @error: the error number 807 * @error: the error number
801 * @msg: the message 808 * @msg: the message
802 * @info1: extra information string 809 * @info1: extra information string
803 * @info2: extra information string 810 * @info2: extra information string
804 * 811 *
805 * Handle a namespace warning error 812 * Handle a namespace warning error
806 */ 813 */
807 static void 814 static void LIBXML_ATTR_FORMAT(3,0)
808 xmlNsWarn(xmlParserCtxtPtr ctxt, xmlParserErrors error, 815 xmlNsWarn(xmlParserCtxtPtr ctxt, xmlParserErrors error,
809 const char *msg, 816 const char *msg,
810 const xmlChar * info1, const xmlChar * info2, 817 const xmlChar * info1, const xmlChar * info2,
811 const xmlChar * info3) 818 const xmlChar * info3)
812 { 819 {
813 if ((ctxt != NULL) && (ctxt->disableSAX != 0) && 820 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
814 (ctxt->instate == XML_PARSER_EOF)) 821 (ctxt->instate == XML_PARSER_EOF))
815 return; 822 return;
816 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error, 823 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error,
817 XML_ERR_WARNING, NULL, 0, (const char *) info1, 824 XML_ERR_WARNING, NULL, 0, (const char *) info1,
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after
2001 * CUR_SCHAR same but operate on a string instead of the context 2008 * CUR_SCHAR same but operate on a string instead of the context
2002 * COPY_BUF copy the current unicode char to the target buffer, increment 2009 * COPY_BUF copy the current unicode char to the target buffer, increment
2003 * the index 2010 * the index
2004 * GROW, SHRINK handling of input buffers 2011 * GROW, SHRINK handling of input buffers
2005 */ 2012 */
2006 2013
2007 #define RAW (*ctxt->input->cur) 2014 #define RAW (*ctxt->input->cur)
2008 #define CUR (*ctxt->input->cur) 2015 #define CUR (*ctxt->input->cur)
2009 #define NXT(val) ctxt->input->cur[(val)] 2016 #define NXT(val) ctxt->input->cur[(val)]
2010 #define CUR_PTR ctxt->input->cur 2017 #define CUR_PTR ctxt->input->cur
2018 #define BASE_PTR ctxt->input->base
2011 2019
2012 #define CMP4( s, c1, c2, c3, c4 ) \ 2020 #define CMP4( s, c1, c2, c3, c4 ) \
2013 ( ((unsigned char *) s)[ 0 ] == c1 && ((unsigned char *) s)[ 1 ] == c2 && \ 2021 ( ((unsigned char *) s)[ 0 ] == c1 && ((unsigned char *) s)[ 1 ] == c2 && \
2014 ((unsigned char *) s)[ 2 ] == c3 && ((unsigned char *) s)[ 3 ] == c4 ) 2022 ((unsigned char *) s)[ 2 ] == c3 && ((unsigned char *) s)[ 3 ] == c4 )
2015 #define CMP5( s, c1, c2, c3, c4, c5 ) \ 2023 #define CMP5( s, c1, c2, c3, c4, c5 ) \
2016 ( CMP4( s, c1, c2, c3, c4 ) && ((unsigned char *) s)[ 4 ] == c5 ) 2024 ( CMP4( s, c1, c2, c3, c4 ) && ((unsigned char *) s)[ 4 ] == c5 )
2017 #define CMP6( s, c1, c2, c3, c4, c5, c6 ) \ 2025 #define CMP6( s, c1, c2, c3, c4, c5, c6 ) \
2018 ( CMP5( s, c1, c2, c3, c4, c5 ) && ((unsigned char *) s)[ 5 ] == c6 ) 2026 ( CMP5( s, c1, c2, c3, c4, c5 ) && ((unsigned char *) s)[ 5 ] == c6 )
2019 #define CMP7( s, c1, c2, c3, c4, c5, c6, c7 ) \ 2027 #define CMP7( s, c1, c2, c3, c4, c5, c6, c7 ) \
2020 ( CMP6( s, c1, c2, c3, c4, c5, c6 ) && ((unsigned char *) s)[ 6 ] == c7 ) 2028 ( CMP6( s, c1, c2, c3, c4, c5, c6 ) && ((unsigned char *) s)[ 6 ] == c7 )
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
2851 xmlGenericError(xmlGenericErrorContext, 2859 xmlGenericError(xmlGenericErrorContext,
2852 "String decoding PE Reference: %.30s\n", str); 2860 "String decoding PE Reference: %.30s\n", str);
2853 ent = xmlParseStringPEReference(ctxt, &str); 2861 ent = xmlParseStringPEReference(ctxt, &str);
2854 if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP) 2862 if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP)
2855 goto int_error; 2863 goto int_error;
2856 xmlParserEntityCheck(ctxt, 0, ent, 0); 2864 xmlParserEntityCheck(ctxt, 0, ent, 0);
2857 if (ent != NULL) 2865 if (ent != NULL)
2858 ctxt->nbentities += ent->checked / 2; 2866 ctxt->nbentities += ent->checked / 2;
2859 if (ent != NULL) { 2867 if (ent != NULL) {
2860 if (ent->content == NULL) { 2868 if (ent->content == NULL) {
2861 » » xmlLoadEntityContent(ctxt, ent); 2869 » » /*
2870 » » * Note: external parsed entities will not be loaded,
2871 » » * it is not required for a non-validating parser to
2872 » » * complete external PEreferences coming from the
2873 » » * internal subset
2874 » » */
2875 » » if (((ctxt->options & XML_PARSE_NOENT) != 0) ||
2876 » » » ((ctxt->options & XML_PARSE_DTDVALID) != 0) ||
2877 » » » (ctxt->validate != 0)) {
2878 » » » xmlLoadEntityContent(ctxt, ent);
2879 » » } else {
2880 » » » xmlWarningMsg(ctxt, XML_ERR_ENTITY_PROCESSING,
2881 » » "not validating will not read content for PE entity %s\n",
2882 » » ent->name, NULL);
2883 » » }
2862 } 2884 }
2863 ctxt->depth++; 2885 ctxt->depth++;
2864 rep = xmlStringDecodeEntities(ctxt, ent->content, what, 2886 rep = xmlStringDecodeEntities(ctxt, ent->content, what,
2865 0, 0, 0); 2887 0, 0, 0);
2866 ctxt->depth--; 2888 ctxt->depth--;
2867 if (rep != NULL) { 2889 if (rep != NULL) {
2868 current = rep; 2890 current = rep;
2869 while (*current != 0) { /* non input consuming loop */ 2891 while (*current != 0) { /* non input consuming loop */
2870 buffer[nbchars++] = *current++; 2892 buffer[nbchars++] = *current++;
2871 if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { 2893 if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
3463 } 3485 }
3464 /* accelerator for special cases */ 3486 /* accelerator for special cases */
3465 return(xmlParseNameComplex(ctxt)); 3487 return(xmlParseNameComplex(ctxt));
3466 } 3488 }
3467 3489
3468 static const xmlChar * 3490 static const xmlChar *
3469 xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) { 3491 xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
3470 int len = 0, l; 3492 int len = 0, l;
3471 int c; 3493 int c;
3472 int count = 0; 3494 int count = 0;
3473 const xmlChar *end; /* needed because CUR_CHAR() can move cur on \r\n */ 3495 size_t startPosition = 0;
3474 3496
3475 #ifdef DEBUG 3497 #ifdef DEBUG
3476 nbParseNCNameComplex++; 3498 nbParseNCNameComplex++;
3477 #endif 3499 #endif
3478 3500
3479 /* 3501 /*
3480 * Handler for more complex cases 3502 * Handler for more complex cases
3481 */ 3503 */
3482 GROW; 3504 GROW;
3483 end = ctxt->input->cur; 3505 startPosition = CUR_PTR - BASE_PTR;
3484 c = CUR_CHAR(l); 3506 c = CUR_CHAR(l);
3485 if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */ 3507 if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */
3486 (!xmlIsNameStartChar(ctxt, c) || (c == ':'))) { 3508 (!xmlIsNameStartChar(ctxt, c) || (c == ':'))) {
3487 return(NULL); 3509 return(NULL);
3488 } 3510 }
3489 3511
3490 while ((c != ' ') && (c != '>') && (c != '/') && /* test bigname.xml */ 3512 while ((c != ' ') && (c != '>') && (c != '/') && /* test bigname.xml */
3491 (xmlIsNameChar(ctxt, c) && (c != ':'))) { 3513 (xmlIsNameChar(ctxt, c) && (c != ':'))) {
3492 if (count++ > XML_PARSER_CHUNK_SIZE) { 3514 if (count++ > XML_PARSER_CHUNK_SIZE) {
3493 if ((len > XML_MAX_NAME_LENGTH) && 3515 if ((len > XML_MAX_NAME_LENGTH) &&
3494 ((ctxt->options & XML_PARSE_HUGE) == 0)) { 3516 ((ctxt->options & XML_PARSE_HUGE) == 0)) {
3495 xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName"); 3517 xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName");
3496 return(NULL); 3518 return(NULL);
3497 } 3519 }
3498 count = 0; 3520 count = 0;
3499 GROW; 3521 GROW;
3500 if (ctxt->instate == XML_PARSER_EOF) 3522 if (ctxt->instate == XML_PARSER_EOF)
3501 return(NULL); 3523 return(NULL);
3502 } 3524 }
3503 len += l; 3525 len += l;
3504 NEXTL(l); 3526 NEXTL(l);
3505 end = ctxt->input->cur;
3506 c = CUR_CHAR(l); 3527 c = CUR_CHAR(l);
3507 if (c == 0) { 3528 if (c == 0) {
3508 count = 0; 3529 count = 0;
3509 /* 3530 /*
3510 * when shrinking to extend the buffer we really need to preserve 3531 * when shrinking to extend the buffer we really need to preserve
3511 * the part of the name we already parsed. Hence rolling back 3532 * the part of the name we already parsed. Hence rolling back
3512 * by current lenght. 3533 * by current lenght.
3513 */ 3534 */
3514 ctxt->input->cur -= l; 3535 ctxt->input->cur -= l;
3515 GROW; 3536 GROW;
3516 ctxt->input->cur += l; 3537 ctxt->input->cur += l;
3517 if (ctxt->instate == XML_PARSER_EOF) 3538 if (ctxt->instate == XML_PARSER_EOF)
3518 return(NULL); 3539 return(NULL);
3519 end = ctxt->input->cur;
3520 c = CUR_CHAR(l); 3540 c = CUR_CHAR(l);
3521 } 3541 }
3522 } 3542 }
3523 if ((len > XML_MAX_NAME_LENGTH) && 3543 if ((len > XML_MAX_NAME_LENGTH) &&
3524 ((ctxt->options & XML_PARSE_HUGE) == 0)) { 3544 ((ctxt->options & XML_PARSE_HUGE) == 0)) {
3525 xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName"); 3545 xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName");
3526 return(NULL); 3546 return(NULL);
3527 } 3547 }
3528 return(xmlDictLookup(ctxt->dict, end - len, len)); 3548 return(xmlDictLookup(ctxt->dict, (BASE_PTR + startPosition), len));
3529 } 3549 }
3530 3550
3531 /** 3551 /**
3532 * xmlParseNCName: 3552 * xmlParseNCName:
3533 * @ctxt: an XML parser context 3553 * @ctxt: an XML parser context
3534 * @len: length of the string parsed 3554 * @len: length of the string parsed
3535 * 3555 *
3536 * parse an XML name. 3556 * parse an XML name.
3537 * 3557 *
3538 * [4NS] NCNameChar ::= Letter | Digit | '.' | '-' | '_' | 3558 * [4NS] NCNameChar ::= Letter | Digit | '.' | '-' | '_' |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
3959 xmlFatalErr(ctxt, XML_ERR_ENTITY_NOT_FINISHED, NULL); 3979 xmlFatalErr(ctxt, XML_ERR_ENTITY_NOT_FINISHED, NULL);
3960 xmlFree(buf); 3980 xmlFree(buf);
3961 } else { 3981 } else {
3962 NEXT; 3982 NEXT;
3963 /* 3983 /*
3964 * NOTE: 4.4.7 Bypassed 3984 * NOTE: 4.4.7 Bypassed
3965 * When a general entity reference appears in the EntityValue in 3985 * When a general entity reference appears in the EntityValue in
3966 * an entity declaration, it is bypassed and left as is. 3986 * an entity declaration, it is bypassed and left as is.
3967 * so XML_SUBSTITUTE_REF is not set here. 3987 * so XML_SUBSTITUTE_REF is not set here.
3968 */ 3988 */
3989 ++ctxt->depth;
3969 ret = xmlStringDecodeEntities(ctxt, buf, XML_SUBSTITUTE_PEREF, 3990 ret = xmlStringDecodeEntities(ctxt, buf, XML_SUBSTITUTE_PEREF,
3970 0, 0, 0); 3991 0, 0, 0);
3992 --ctxt->depth;
3971 if (orig != NULL) 3993 if (orig != NULL)
3972 *orig = buf; 3994 *orig = buf;
3973 else 3995 else
3974 xmlFree(buf); 3996 xmlFree(buf);
3975 } 3997 }
3976 3998
3977 return(ret); 3999 return(ret);
3978 } 4000 }
3979 4001
3980 /** 4002 /**
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
4085 buf[len++] = '#'; 4107 buf[len++] = '#';
4086 buf[len++] = '3'; 4108 buf[len++] = '3';
4087 buf[len++] = '8'; 4109 buf[len++] = '8';
4088 buf[len++] = ';'; 4110 buf[len++] = ';';
4089 } else { 4111 } else {
4090 buf[len++] = ent->content[0]; 4112 buf[len++] = ent->content[0];
4091 } 4113 }
4092 } else if ((ent != NULL) && 4114 } else if ((ent != NULL) &&
4093 (ctxt->replaceEntities != 0)) { 4115 (ctxt->replaceEntities != 0)) {
4094 if (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) { 4116 if (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) {
4117 ++ctxt->depth;
4095 rep = xmlStringDecodeEntities(ctxt, ent->content, 4118 rep = xmlStringDecodeEntities(ctxt, ent->content,
4096 XML_SUBSTITUTE_REF, 4119 XML_SUBSTITUTE_REF,
4097 0, 0, 0); 4120 0, 0, 0);
4121 --ctxt->depth;
4098 if (rep != NULL) { 4122 if (rep != NULL) {
4099 current = rep; 4123 current = rep;
4100 while (*current != 0) { /* non input consuming */ 4124 while (*current != 0) { /* non input consuming */
4101 if ((*current == 0xD) || (*current == 0xA) || 4125 if ((*current == 0xD) || (*current == 0xA) ||
4102 (*current == 0x9)) { 4126 (*current == 0x9)) {
4103 buf[len++] = 0x20; 4127 buf[len++] = 0x20;
4104 current++; 4128 current++;
4105 } else 4129 } else
4106 buf[len++] = *current++; 4130 buf[len++] = *current++;
4107 if (len + 10 > buf_size) { 4131 if (len + 10 > buf_size) {
(...skipping 15 matching lines...) Expand all
4123 const xmlChar *cur = ent->name; 4147 const xmlChar *cur = ent->name;
4124 4148
4125 /* 4149 /*
4126 * This may look absurd but is needed to detect 4150 * This may look absurd but is needed to detect
4127 * entities problems 4151 * entities problems
4128 */ 4152 */
4129 if ((ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) && 4153 if ((ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
4130 (ent->content != NULL) && (ent->checked == 0)) { 4154 (ent->content != NULL) && (ent->checked == 0)) {
4131 unsigned long oldnbent = ctxt->nbentities; 4155 unsigned long oldnbent = ctxt->nbentities;
4132 4156
4157 ++ctxt->depth;
4133 rep = xmlStringDecodeEntities(ctxt, ent->content, 4158 rep = xmlStringDecodeEntities(ctxt, ent->content,
4134 XML_SUBSTITUTE_REF, 0, 0, 0); 4159 XML_SUBSTITUTE_REF, 0, 0, 0);
4160 --ctxt->depth;
4135 4161
4136 ent->checked = (ctxt->nbentities - oldnbent + 1) * 2; 4162 ent->checked = (ctxt->nbentities - oldnbent + 1) * 2;
4137 if (rep != NULL) { 4163 if (rep != NULL) {
4138 if (xmlStrchr(rep, '<')) 4164 if (xmlStrchr(rep, '<'))
4139 ent->checked |= 1; 4165 ent->checked |= 1;
4140 xmlFree(rep); 4166 xmlFree(rep);
4141 rep = NULL; 4167 rep = NULL;
4142 } 4168 }
4143 } 4169 }
4144 4170
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after
5494 if (skipped == 0) { 5520 if (skipped == 0) {
5495 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, 5521 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5496 "Space required after '<!ENTITY'\n"); 5522 "Space required after '<!ENTITY'\n");
5497 } 5523 }
5498 5524
5499 if (RAW == '%') { 5525 if (RAW == '%') {
5500 NEXT; 5526 NEXT;
5501 skipped = SKIP_BLANKS; 5527 skipped = SKIP_BLANKS;
5502 if (skipped == 0) { 5528 if (skipped == 0) {
5503 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, 5529 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5504 » » » "Space required after '%'\n"); 5530 » » » "Space required after '%%'\n");
5505 } 5531 }
5506 isParameter = 1; 5532 isParameter = 1;
5507 } 5533 }
5508 5534
5509 name = xmlParseName(ctxt); 5535 name = xmlParseName(ctxt);
5510 if (name == NULL) { 5536 if (name == NULL) {
5511 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED, 5537 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
5512 "xmlParseEntityDecl: no name\n"); 5538 "xmlParseEntityDecl: no name\n");
5513 return; 5539 return;
5514 } 5540 }
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after
6679 xmlElementContentPtr content = NULL; 6705 xmlElementContentPtr content = NULL;
6680 6706
6681 /* GROW; done in the caller */ 6707 /* GROW; done in the caller */
6682 if (CMP9(CUR_PTR, '<', '!', 'E', 'L', 'E', 'M', 'E', 'N', 'T')) { 6708 if (CMP9(CUR_PTR, '<', '!', 'E', 'L', 'E', 'M', 'E', 'N', 'T')) {
6683 xmlParserInputPtr input = ctxt->input; 6709 xmlParserInputPtr input = ctxt->input;
6684 6710
6685 SKIP(9); 6711 SKIP(9);
6686 if (!IS_BLANK_CH(CUR)) { 6712 if (!IS_BLANK_CH(CUR)) {
6687 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, 6713 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6688 "Space required after 'ELEMENT'\n"); 6714 "Space required after 'ELEMENT'\n");
6715 return(-1);
6689 } 6716 }
6690 SKIP_BLANKS; 6717 SKIP_BLANKS;
6691 name = xmlParseName(ctxt); 6718 name = xmlParseName(ctxt);
6692 if (name == NULL) { 6719 if (name == NULL) {
6693 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED, 6720 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6694 "xmlParseElementDecl: no name for Element\n"); 6721 "xmlParseElementDecl: no name for Element\n");
6695 return(-1); 6722 return(-1);
6696 } 6723 }
6697 while ((RAW == 0) && (ctxt->inputNr > 1)) 6724 while ((RAW == 0) && (ctxt->inputNr > 1))
6698 xmlPopInput(ctxt); 6725 xmlPopInput(ctxt);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
6830 xmlParseMarkupDecl(ctxt); 6857 xmlParseMarkupDecl(ctxt);
6831 6858
6832 /* 6859 /*
6833 * Pop-up of finished entities. 6860 * Pop-up of finished entities.
6834 */ 6861 */
6835 while ((RAW == 0) && (ctxt->inputNr > 1)) 6862 while ((RAW == 0) && (ctxt->inputNr > 1))
6836 xmlPopInput(ctxt); 6863 xmlPopInput(ctxt);
6837 6864
6838 if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) { 6865 if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) {
6839 xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL); 6866 xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL);
6867 xmlHaltParser(ctxt);
6840 break; 6868 break;
6841 } 6869 }
6842 } 6870 }
6843 if (xmlParserDebugEntities) { 6871 if (xmlParserDebugEntities) {
6844 if ((ctxt->input != NULL) && (ctxt->input->filename)) 6872 if ((ctxt->input != NULL) && (ctxt->input->filename))
6845 xmlGenericError(xmlGenericErrorContext, 6873 xmlGenericError(xmlGenericErrorContext,
6846 "%s(%d): ", ctxt->input->filename, 6874 "%s(%d): ", ctxt->input->filename,
6847 ctxt->input->line); 6875 ctxt->input->line);
6848 xmlGenericError(xmlGenericErrorContext, 6876 xmlGenericError(xmlGenericErrorContext,
6849 "Leaving INCLUDE Conditional Section\n"); 6877 "Leaving INCLUDE Conditional Section\n");
(...skipping 2609 matching lines...) Expand 10 before | Expand all | Expand 10 after
9459 * check that it's not a defined namespace 9487 * check that it's not a defined namespace
9460 */ 9488 */
9461 for (j = 1;j <= nbNs;j++) 9489 for (j = 1;j <= nbNs;j++)
9462 if (ctxt->nsTab[ctxt->nsNr - 2 * j] == NULL) 9490 if (ctxt->nsTab[ctxt->nsNr - 2 * j] == NULL)
9463 break; 9491 break;
9464 if (j <= nbNs) 9492 if (j <= nbNs)
9465 xmlErrAttributeDup(ctxt, NULL, attname); 9493 xmlErrAttributeDup(ctxt, NULL, attname);
9466 else 9494 else
9467 if (nsPush(ctxt, NULL, URL) > 0) nbNs++; 9495 if (nsPush(ctxt, NULL, URL) > 0) nbNs++;
9468 skip_default_ns: 9496 skip_default_ns:
9469 » » if (alloc != 0) xmlFree(attvalue); 9497 » » if ((attvalue != NULL) && (alloc != 0)) {
9498 » » xmlFree(attvalue);
9499 » » attvalue = NULL;
9500 » » }
9470 if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>')))) 9501 if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>'))))
9471 break; 9502 break;
9472 if (!IS_BLANK_CH(RAW)) { 9503 if (!IS_BLANK_CH(RAW)) {
9473 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, 9504 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
9474 "attributes construct error\n"); 9505 "attributes construct error\n");
9475 break; 9506 break;
9476 } 9507 }
9477 SKIP_BLANKS; 9508 SKIP_BLANKS;
9509 if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))
9510 goto base_changed;
9478 continue; 9511 continue;
9479 } 9512 }
9480 if (aprefix == ctxt->str_xmlns) { 9513 if (aprefix == ctxt->str_xmlns) {
9481 const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len); 9514 const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len);
9482 xmlURIPtr uri; 9515 xmlURIPtr uri;
9483 9516
9484 if (attname == ctxt->str_xml) { 9517 if (attname == ctxt->str_xml) {
9485 if (URL != ctxt->str_xml_ns) { 9518 if (URL != ctxt->str_xml_ns) {
9486 xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE, 9519 xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
9487 "xml namespace prefix mapped to wrong URI\n", 9520 "xml namespace prefix mapped to wrong URI\n",
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
9539 * check that it's not a defined namespace 9572 * check that it's not a defined namespace
9540 */ 9573 */
9541 for (j = 1;j <= nbNs;j++) 9574 for (j = 1;j <= nbNs;j++)
9542 if (ctxt->nsTab[ctxt->nsNr - 2 * j] == attname) 9575 if (ctxt->nsTab[ctxt->nsNr - 2 * j] == attname)
9543 break; 9576 break;
9544 if (j <= nbNs) 9577 if (j <= nbNs)
9545 xmlErrAttributeDup(ctxt, aprefix, attname); 9578 xmlErrAttributeDup(ctxt, aprefix, attname);
9546 else 9579 else
9547 if (nsPush(ctxt, attname, URL) > 0) nbNs++; 9580 if (nsPush(ctxt, attname, URL) > 0) nbNs++;
9548 skip_ns: 9581 skip_ns:
9549 » » if (alloc != 0) xmlFree(attvalue); 9582 » » if ((attvalue != NULL) && (alloc != 0)) {
9583 » » xmlFree(attvalue);
9584 » » attvalue = NULL;
9585 » » }
9550 if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>')))) 9586 if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>'))))
9551 break; 9587 break;
9552 if (!IS_BLANK_CH(RAW)) { 9588 if (!IS_BLANK_CH(RAW)) {
9553 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, 9589 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
9554 "attributes construct error\n"); 9590 "attributes construct error\n");
9555 break; 9591 break;
9556 } 9592 }
9557 SKIP_BLANKS; 9593 SKIP_BLANKS;
9558 if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr)) 9594 if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))
9559 goto base_changed; 9595 goto base_changed;
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
9810 * 9846 *
9811 * With namespace 9847 * With namespace
9812 * 9848 *
9813 * [NS 9] ETag ::= '</' QName S? '>' 9849 * [NS 9] ETag ::= '</' QName S? '>'
9814 */ 9850 */
9815 9851
9816 static void 9852 static void
9817 xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlChar *prefix, 9853 xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlChar *prefix,
9818 const xmlChar *URI, int line, int nsNr, int tlen) { 9854 const xmlChar *URI, int line, int nsNr, int tlen) {
9819 const xmlChar *name; 9855 const xmlChar *name;
9856 size_t curLength;
9820 9857
9821 GROW; 9858 GROW;
9822 if ((RAW != '<') || (NXT(1) != '/')) { 9859 if ((RAW != '<') || (NXT(1) != '/')) {
9823 xmlFatalErr(ctxt, XML_ERR_LTSLASH_REQUIRED, NULL); 9860 xmlFatalErr(ctxt, XML_ERR_LTSLASH_REQUIRED, NULL);
9824 return; 9861 return;
9825 } 9862 }
9826 SKIP(2); 9863 SKIP(2);
9827 9864
9828 size_t curLength = ctxt->input->end - ctxt->input->cur; 9865 curLength = ctxt->input->end - ctxt->input->cur;
9829 if ((tlen > 0) && (curLength >= (size_t)tlen) && (xmlStrncmp(ctxt->input->cu r, ctxt->name, tlen) == 0)) { 9866 if ((tlen > 0) && (curLength >= (size_t)tlen) &&
9830 if ((curLength >= (size_t)(tlen + 1)) && (ctxt->input->cur[tlen] == '>')) { 9867 (xmlStrncmp(ctxt->input->cur, ctxt->name, tlen) == 0)) {
9868 if ((curLength >= (size_t)(tlen + 1)) &&
9869 » (ctxt->input->cur[tlen] == '>')) {
9831 ctxt->input->cur += tlen + 1; 9870 ctxt->input->cur += tlen + 1;
9832 ctxt->input->col += tlen + 1; 9871 ctxt->input->col += tlen + 1;
9833 goto done; 9872 goto done;
9834 } 9873 }
9835 ctxt->input->cur += tlen; 9874 ctxt->input->cur += tlen;
9836 ctxt->input->col += tlen; 9875 ctxt->input->col += tlen;
9837 name = (xmlChar*)1; 9876 name = (xmlChar*)1;
9838 } else { 9877 } else {
9839 if (prefix == NULL) 9878 if (prefix == NULL)
9840 name = xmlParseNameAndCompare(ctxt, ctxt->name); 9879 name = xmlParseNameAndCompare(ctxt, ctxt->name);
(...skipping 5928 matching lines...) Expand 10 before | Expand all | Expand 10 after
15769 if (stream == NULL) { 15808 if (stream == NULL) {
15770 xmlFreeParserInputBuffer(input); 15809 xmlFreeParserInputBuffer(input);
15771 return (NULL); 15810 return (NULL);
15772 } 15811 }
15773 inputPush(ctxt, stream); 15812 inputPush(ctxt, stream);
15774 return (xmlDoRead(ctxt, URL, encoding, options, 1)); 15813 return (xmlDoRead(ctxt, URL, encoding, options, 1));
15775 } 15814 }
15776 15815
15777 #define bottom_parser 15816 #define bottom_parser
15778 #include "elfgcchack.h" 15817 #include "elfgcchack.h"
OLDNEW
« no previous file with comments | « third_party/libxml/src/macos/src/macos_main.c ('k') | third_party/libxml/src/parserInternals.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698