Overview
Comment: | Pass the parser for OFMalformedXMLExceptions. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
3a9a5001cf30a0116cdd2bb9a574cb9f |
User & Date: | js on 2011-03-24 21:29:14 |
Other Links: | manifest | tags |
Context
2011-03-25
| ||
01:56 |
Link against -lnetwork if available. Haiku requires this. check-in: 83afc487f8 user: js tags: trunk | |
2011-03-24
| ||
21:29 | Pass the parser for OFMalformedXMLExceptions. check-in: 3a9a5001cf user: js tags: trunk | |
21:17 | Pass the stream for stream exceptions. check-in: 7ced2e7b6a user: js tags: trunk | |
Changes
Modified src/OFXMLElementBuilder.m from [0a10d296cf] to [23f4713294].
︙ | ︙ | |||
177 178 179 180 181 182 183 | } - (void)elementBuilder: (OFXMLElementBuilder*)builder didNotExpectCloseTag: (OFString*)name withPrefix: (OFString*)prefix namespace: (OFString*)ns { | | > | 177 178 179 180 181 182 183 184 185 186 187 | } - (void)elementBuilder: (OFXMLElementBuilder*)builder didNotExpectCloseTag: (OFString*)name withPrefix: (OFString*)prefix namespace: (OFString*)ns { @throw [OFMalformedXMLException newWithClass: [builder class] parser: nil]; } @end |
Modified src/OFXMLParser.m from [cfc14f4098] to [e1f46dcc8c].
︙ | ︙ | |||
276 277 278 279 280 281 282 | i: (size_t*)i last: (size_t*)last { size_t len; if (finishedParsing && buf[*i] != ' ' && buf[*i] != '\t' && buf[*i] != '\n' && buf[*i] != '\r' && buf[*i] != '<') | | > | 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | i: (size_t*)i last: (size_t*)last { size_t len; if (finishedParsing && buf[*i] != ' ' && buf[*i] != '\t' && buf[*i] != '\n' && buf[*i] != '\r' && buf[*i] != '<') @throw [OFMalformedXMLException newWithClass: isa parser: self]; if (buf[*i] != '<') return; if ((len = *i - *last) > 0) [cache appendCStringWithoutUTF8Checking: buf + *last length: len]; |
︙ | ︙ | |||
315 316 317 318 319 320 321 | /* Tag was just opened */ - (void)_parseTagOpenedWithBuffer: (const char*)buf i: (size_t*)i last: (size_t*)last { if (finishedParsing && buf[*i] != '!') | | > | 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | /* Tag was just opened */ - (void)_parseTagOpenedWithBuffer: (const char*)buf i: (size_t*)i last: (size_t*)last { if (finishedParsing && buf[*i] != '!') @throw [OFMalformedXMLException newWithClass: isa parser: self]; switch (buf[*i]) { case '?': *last = *i + 1; state = OF_XMLPARSER_IN_PROCESSING_INSTRUCTIONS; level = 0; break; |
︙ | ︙ | |||
501 502 503 504 505 506 507 | length: tmp - cache_c]; } else { name = [cache copy]; prefix = nil; } if (![[previous lastObject] isEqual: cache]) | | > | 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 | length: tmp - cache_c]; } else { name = [cache copy]; prefix = nil; } if (![[previous lastObject] isEqual: cache]) @throw [OFMalformedXMLException newWithClass: isa parser: self]; [previous removeNObjects: 1]; [cache setToCString: ""]; ns = namespace_for_prefix(prefix, namespaces); if (prefix != nil && ns == nil) |
︙ | ︙ | |||
668 669 670 671 672 673 674 | *last = *i + 1; if (buf[*i] == ' ' || buf[*i] == '\t' || buf[*i] == '\n' || buf[*i] == '\r') return; if (buf[*i] != '\'' && buf[*i] != '"') | | > | 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 | *last = *i + 1; if (buf[*i] == ' ' || buf[*i] == '\t' || buf[*i] == '\n' || buf[*i] == '\r') return; if (buf[*i] != '\'' && buf[*i] != '"') @throw [OFMalformedXMLException newWithClass: isa parser: self]; delim = buf[*i]; state = OF_XMLPARSER_IN_ATTR_VALUE; } /* Looking for attribute value */ - (void)_parseInAttributeValueWithBuffer: (const char*)buf |
︙ | ︙ | |||
727 728 729 730 731 732 733 | i: (size_t*)i last: (size_t*)last { if (buf[*i] == '>') { *last = *i + 1; state = OF_XMLPARSER_OUTSIDE_TAG; } else | | > | > | > | > | > | 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 | i: (size_t*)i last: (size_t*)last { if (buf[*i] == '>') { *last = *i + 1; state = OF_XMLPARSER_OUTSIDE_TAG; } else @throw [OFMalformedXMLException newWithClass: isa parser: self]; } /* Expecting closing '>' or space */ - (void)_parseExpectSpaceOrCloseWithBuffer: (const char*)buf i: (size_t*)i last: (size_t*)last { if (buf[*i] == '>') { *last = *i + 1; state = OF_XMLPARSER_OUTSIDE_TAG; } else if (buf[*i] != ' ' && buf[*i] != '\t' && buf[*i] != '\n' && buf[*i] != '\r') @throw [OFMalformedXMLException newWithClass: isa parser: self]; } /* In <! */ - (void)_parseInExclamationMarkWithBuffer: (const char*)buf i: (size_t*)i last: (size_t*)last { if (finishedParsing && buf[*i] != '-') @throw [OFMalformedXMLException newWithClass: isa parser: self]; if (buf[*i] == '-') state = OF_XMLPARSER_IN_COMMENT_OPENING; else if (buf[*i] == '[') { state = OF_XMLPARSER_IN_CDATA_OPENING; level = 0; } else if (buf[*i] == 'D') { state = OF_XMLPARSER_IN_DOCTYPE; level = 0; } else @throw [OFMalformedXMLException newWithClass: isa parser: self]; *last = *i + 1; } /* CDATA */ - (void)_parseInCDATAOpeningWithBuffer: (const char*)buf i: (size_t*)i last: (size_t*)last { if (buf[*i] != "CDATA["[level]) @throw [OFMalformedXMLException newWithClass: isa parser: self]; if (++level == 6) { state = OF_XMLPARSER_IN_CDATA_1; level = 0; } *last = *i + 1; |
︙ | ︙ | |||
848 849 850 851 852 853 854 | /* Comment */ - (void)_parseInCommentOpeningWithBuffer: (const char*)buf i: (size_t*)i last: (size_t*)last { if (buf[*i] != '-') | | > | 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 | /* Comment */ - (void)_parseInCommentOpeningWithBuffer: (const char*)buf i: (size_t*)i last: (size_t*)last { if (buf[*i] != '-') @throw [OFMalformedXMLException newWithClass: isa parser: self]; *last = *i + 1; state = OF_XMLPARSER_IN_COMMENT_1; level = 0; } - (void)_parseInComment1WithBuffer: (const char*)buf |
︙ | ︙ | |||
877 878 879 880 881 882 883 | last: (size_t*)last { OFAutoreleasePool *pool; OFMutableString *comment; size_t len; if (buf[*i] != '>') | | > | 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 | last: (size_t*)last { OFAutoreleasePool *pool; OFMutableString *comment; size_t len; if (buf[*i] != '>') @throw [OFMalformedXMLException newWithClass: isa parser: self]; pool = [[OFAutoreleasePool alloc] init]; [cache appendCStringWithoutUTF8Checking: buf + *last length: *i - *last]; comment = [[cache mutableCopy] autorelease]; len = [comment length]; |
︙ | ︙ | |||
920 921 922 923 924 925 926 | - (void)_parseInDoctypeWithBuffer: (const char*)buf i: (size_t*)i last: (size_t*)last { if ((level < 6 && buf[*i] != "OCTYPE"[level]) || (level == 6 && buf[*i] != ' ' && buf[*i] != '\t' && buf[*i] != '\n' && buf[*i] != '\r')) | | > | 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 | - (void)_parseInDoctypeWithBuffer: (const char*)buf i: (size_t*)i last: (size_t*)last { if ((level < 6 && buf[*i] != "OCTYPE"[level]) || (level == 6 && buf[*i] != ' ' && buf[*i] != '\t' && buf[*i] != '\n' && buf[*i] != '\r')) @throw [OFMalformedXMLException newWithClass: isa parser: self]; if (level < 7 || buf[*i] == '<') level++; if (buf[*i] == '>') { if (level == 7) state = OF_XMLPARSER_OUTSIDE_TAG; |
︙ | ︙ |
Modified src/exceptions/OFMalformedXMLException.h from [8e73d4285a] to [eb34a728c6].
︙ | ︙ | |||
12 13 14 15 16 17 18 19 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFException.h" /** | > > | < > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFException.h" @class OFXMLParser; /** * \brief An exception indicating that a parser encountered malformed XML. */ @interface OFMalformedXMLException: OFException { OFXMLParser *parser; } #ifdef OF_HAVE_PROPERTIES @property (readonly, nonatomic) OFXMLParser *parser; #endif /** * \param parser The parser which encountered malformed XML * \return A new malformed XML exception */ + newWithClass: (Class)class_ parser: (OFXMLParser*)parser; /** * Initializes an already allocated malformed XML exception. * * \param parser The parser which encountered malformed XML * \return An initialized malformed XML exception */ - initWithClass: (Class)class_ parser: (OFXMLParser*)parser; /** * \return The parser which encountered malformed XML */ - (OFXMLParser*)parser; @end |
Modified src/exceptions/OFMalformedXMLException.m from [9767318faa] to [ca2ee2fed4].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | * file. */ #include "config.h" #import "OFMalformedXMLException.h" #import "OFString.h" @implementation OFMalformedXMLException - (OFString*)description { if (description != nil) return description; description = [[OFString alloc] initWithFormat: @"The parser in class %@ encountered malformed XML!", inClass]; return description; } @end | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | * file. */ #include "config.h" #import "OFMalformedXMLException.h" #import "OFString.h" #import "OFNotImplementedException.h" @implementation OFMalformedXMLException + newWithClass: (Class)class_ parser: (OFXMLParser*)parser { return [[self alloc] initWithClass: class_ parser: parser]; } - initWithClass: (Class)class_ { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithClass: (Class)class_ parser: (OFXMLParser*)parser_ { self = [super initWithClass: class_]; @try { parser = [parser_ retain]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [parser release]; [super dealloc]; } - (OFString*)description { if (description != nil) return description; description = [[OFString alloc] initWithFormat: @"The parser in class %@ encountered malformed XML!", inClass]; return description; } - (OFXMLParser*)parser { return parser; } @end |