Differences From Artifact [006e6e5905]:
- File
src/OFXMLParser.m
— part of check-in
[13ee56edf3]
at
2014-06-21 21:43:43
on branch trunk
— Move all macros from OFObject.h to macros.h
This means that OFObject.h imports macros.h now, making it unnecessary
to manually import macros.h in almost every file. And while at it, also
import autorelease.h in OFObject.h, so that this doesn't need to be
manually imported in almost every file as well. (user: js, size: 24323) [annotate] [blame] [check-ins using]
To Artifact [7ca3cc1d6a]:
- File
src/OFXMLParser.m
— part of check-in
[6e5a920567]
at
2014-07-07 22:05:11
on branch trunk
— Add OFUnknownXMLEntityException
Additionally, OFXMLParser now uses OFMalformedXMLException instead of
OFInvalidFormatException on invalid entities. (user: js, size: 24471) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #import "OFStream.h" #ifdef OF_HAVE_FILES # import "OFFile.h" #endif #import "OFSystemInfo.h" #import "OFInitializationFailedException.h" #import "OFMalformedXMLException.h" #import "OFUnboundPrefixException.h" typedef void (*state_function_t)(id, SEL); static SEL selectors[OF_XMLPARSER_NUM_STATES]; static state_function_t lookupTable[OF_XMLPARSER_NUM_STATES]; | > | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #import "OFStream.h" #ifdef OF_HAVE_FILES # import "OFFile.h" #endif #import "OFSystemInfo.h" #import "OFInitializationFailedException.h" #import "OFInvalidFormatException.h" #import "OFMalformedXMLException.h" #import "OFUnboundPrefixException.h" typedef void (*state_function_t)(id, SEL); static SEL selectors[OF_XMLPARSER_NUM_STATES]; static state_function_t lookupTable[OF_XMLPARSER_NUM_STATES]; |
︙ | ︙ | |||
55 56 57 58 59 60 61 | [buffer addItems: [tmp UTF8String] count: [tmp UTF8StringLength]]; objc_autoreleasePoolPop(pool); } } static OFString* | | | | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | [buffer addItems: [tmp UTF8String] count: [tmp UTF8StringLength]]; objc_autoreleasePoolPop(pool); } } static OFString* transformString(OFXMLParser *parser, OFDataArray *buffer, size_t cut, bool unescape) { char *items; size_t i, length; bool hasEntities = false; OFString *ret; items = [buffer items]; |
︙ | ︙ | |||
83 84 85 86 87 88 89 | } else if (items[i] == '&') hasEntities = true; } ret = [OFString stringWithUTF8String: items length: length]; | | > | > > > > > | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | } else if (items[i] == '&') hasEntities = true; } ret = [OFString stringWithUTF8String: items length: length]; if (unescape && hasEntities) { @try { return [ret stringByXMLUnescapingWithDelegate: parser]; } @catch (OFInvalidFormatException *e) { @throw [OFMalformedXMLException exceptionWithParser: parser]; } } return ret; } static OFString* namespaceForPrefix(OFString *prefix, OFArray *namespaces) { |
︙ | ︙ | |||
347 348 349 350 351 352 353 | return; if ((length = _i - _last) > 0) appendToBuffer(_buffer, _data + _last, _encoding, length); if ([_buffer count] > 0) { void *pool = objc_autoreleasePoolPush(); | | | 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | return; if ((length = _i - _last) > 0) appendToBuffer(_buffer, _data + _last, _encoding, length); if ([_buffer count] > 0) { void *pool = objc_autoreleasePoolPush(); OFString *characters = transformString(self, _buffer, 0, true); if ([_delegate respondsToSelector: @selector(parser:foundCharacters:)]) [_delegate parser: self foundCharacters: characters]; objc_autoreleasePoolPop(pool); |
︙ | ︙ | |||
509 510 511 512 513 514 515 | if (_data[_i] == '?') _level = 1; else if (_level == 1 && _data[_i] == '>') { void *pool = objc_autoreleasePoolPush(); OFString *PI; appendToBuffer(_buffer, _data + _last, _encoding, _i - _last); | | | 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 | if (_data[_i] == '?') _level = 1; else if (_level == 1 && _data[_i] == '>') { void *pool = objc_autoreleasePoolPush(); OFString *PI; appendToBuffer(_buffer, _data + _last, _encoding, _i - _last); PI = transformString(self, _buffer, 1, false); if ([PI isEqual: @"xml"] || [PI hasPrefix: @"xml "] || [PI hasPrefix: @"xml\t"] || [PI hasPrefix: @"xml\r"] || [PI hasPrefix: @"xml\n"]) if (![self OF_parseXMLProcessingInstructions: PI]) @throw [OFMalformedXMLException exceptionWithParser: self]; |
︙ | ︙ | |||
852 853 854 855 856 857 858 | if (_data[_i] != _delimiter) return; if ((length = _i - _last) > 0) appendToBuffer(_buffer, _data + _last, _encoding, length); pool = objc_autoreleasePoolPush(); | | | 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 | if (_data[_i] != _delimiter) return; if ((length = _i - _last) > 0) appendToBuffer(_buffer, _data + _last, _encoding, length); pool = objc_autoreleasePoolPush(); attributeValue = transformString(self, _buffer, 0, true); if (_attributePrefix == nil && [_attributeName isEqual: @"xmlns"]) [[_namespaces lastObject] setObject: attributeValue forKey: @""]; if ([_attributePrefix isEqual: @"xmlns"]) [[_namespaces lastObject] setObject: attributeValue forKey: _attributeName]; |
︙ | ︙ | |||
942 943 944 945 946 947 948 | if (_data[_i] == ']') _level++; else if (_data[_i] == '>' && _level >= 2) { void *pool = objc_autoreleasePoolPush(); OFString *CDATA; appendToBuffer(_buffer, _data + _last, _encoding, _i - _last); | | | 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 | if (_data[_i] == ']') _level++; else if (_data[_i] == '>' && _level >= 2) { void *pool = objc_autoreleasePoolPush(); OFString *CDATA; appendToBuffer(_buffer, _data + _last, _encoding, _i - _last); CDATA = transformString(self, _buffer, 2, false); if ([_delegate respondsToSelector: @selector(parser:foundCDATA:)]) [_delegate parser: self foundCDATA: CDATA]; objc_autoreleasePoolPop(pool); |
︙ | ︙ | |||
992 993 994 995 996 997 998 | if (_data[_i] != '>') @throw [OFMalformedXMLException exceptionWithParser: self]; pool = objc_autoreleasePoolPush(); appendToBuffer(_buffer, _data + _last, _encoding, _i - _last); | | | 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 | if (_data[_i] != '>') @throw [OFMalformedXMLException exceptionWithParser: self]; pool = objc_autoreleasePoolPush(); appendToBuffer(_buffer, _data + _last, _encoding, _i - _last); comment = transformString(self, _buffer, 2, false); if ([_delegate respondsToSelector: @selector(parser:foundComment:)]) [_delegate parser: self foundComment: comment]; objc_autoreleasePoolPop(pool); |
︙ | ︙ |