ObjFW  Check-in [1c9c536749]

Overview
Comment:Don't treat \f as whitespace in XML.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1c9c5367492164b5db504c74fd29d2f6f93639411e37e3564151379555b29158
User & Date: js on 2012-01-25 20:11:59
Other Links: manifest | tags
Context
2012-01-30
22:56
The new Apple runtime requires +[load] in OFConstantString. check-in: 08389242d9 user: js tags: trunk
2012-01-25
20:11
Don't treat \f as whitespace in XML. check-in: 1c9c536749 user: js tags: trunk
20:00
Update Xcode project. check-in: 7d548c1262 user: js tags: trunk
Changes

Modified src/OFXMLParser.m from [90301d3556] to [14f7ba420b].

305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
				 i: (size_t*)i
			      last: (size_t*)last
{
	size_t length;

	if ((finishedParsing || [previous count] < 1) && buffer[*i] != ' ' &&
	    buffer[*i] != '\t' && buffer[*i] != '\n' && buffer[*i] != '\r' &&
	    buffer[*i] != '\f' && buffer[*i] != '<')
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];

	if (buffer[*i] != '<')
		return;

	if ((length = *i - *last) > 0)







|







305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
				 i: (size_t*)i
			      last: (size_t*)last
{
	size_t length;

	if ((finishedParsing || [previous count] < 1) && buffer[*i] != ' ' &&
	    buffer[*i] != '\t' && buffer[*i] != '\n' && buffer[*i] != '\r' &&
	    buffer[*i] != '<')
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];

	if (buffer[*i] != '<')
		return;

	if ((length = *i - *last) > 0)
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
			     last: (size_t*)last
{
	if (finishedParsing && buffer[*i] != '!' && buffer[*i] != '?')
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];

	switch (buffer[*i]) {
		case '?':
			*last = *i + 1;
			state = OF_XMLPARSER_IN_PROCESSING_INSTRUCTIONS;
			level = 0;
			break;
		case '/':
			*last = *i + 1;
			state = OF_XMLPARSER_IN_CLOSE_TAG_NAME;
			acceptProlog = NO;
			break;
		case '!':
			*last = *i + 1;
			state = OF_XMLPARSER_IN_EXCLAMATIONMARK;
			acceptProlog = NO;
			break;
		default:
			state = OF_XMLPARSER_IN_TAG_NAME;
			acceptProlog = NO;
			(*i)--;
			break;
	}
}

/* <?xml […]?> */
- (BOOL)_parseXMLProcessingInstructions: (OFString*)pi
{
	const char *cString;







|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
			     last: (size_t*)last
{
	if (finishedParsing && buffer[*i] != '!' && buffer[*i] != '?')
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];

	switch (buffer[*i]) {
	case '?':
		*last = *i + 1;
		state = OF_XMLPARSER_IN_PROCESSING_INSTRUCTIONS;
		level = 0;
		break;
	case '/':
		*last = *i + 1;
		state = OF_XMLPARSER_IN_CLOSE_TAG_NAME;
		acceptProlog = NO;
		break;
	case '!':
		*last = *i + 1;
		state = OF_XMLPARSER_IN_EXCLAMATIONMARK;
		acceptProlog = NO;
		break;
	default:
		state = OF_XMLPARSER_IN_TAG_NAME;
		acceptProlog = NO;
		(*i)--;
		break;
	}
}

/* <?xml […]?> */
- (BOOL)_parseXMLProcessingInstructions: (OFString*)pi
{
	const char *cString;
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
	cString = [pi UTF8String];
	length = [pi UTF8StringLength];

	for (i = last = 0; i < length; i++) {
		switch (piState) {
		case 0:
			if (cString[i] == ' ' || cString[i] == '\t' ||
			    cString[i] == '\r' || cString[i] == '\n' ||
			    cString[i] == '\f')
				continue;

			last = i;
			piState = 1;
			i--;

			break;







|
<







392
393
394
395
396
397
398
399

400
401
402
403
404
405
406
	cString = [pi UTF8String];
	length = [pi UTF8StringLength];

	for (i = last = 0; i < length; i++) {
		switch (piState) {
		case 0:
			if (cString[i] == ' ' || cString[i] == '\t' ||
			    cString[i] == '\r' || cString[i] == '\n')

				continue;

			last = i;
			piState = 1;
			i--;

			break;
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
{
	OFAutoreleasePool *pool;
	const char *cacheCString, *tmp;
	size_t length, cacheLength;
	OFString *cacheString;

	if (buffer[*i] != ' ' && buffer[*i] != '\t' && buffer[*i] != '\n' &&
	    buffer[*i] != '\r' && buffer[*i] != '\f' && buffer[*i] != '>' &&
	    buffer[*i] != '/')
		return;

	if ((length = *i - *last) > 0)
		cache_append(cache, buffer + *last, encoding, length);

	pool = [[OFAutoreleasePool alloc] init];








|
<







509
510
511
512
513
514
515
516

517
518
519
520
521
522
523
{
	OFAutoreleasePool *pool;
	const char *cacheCString, *tmp;
	size_t length, cacheLength;
	OFString *cacheString;

	if (buffer[*i] != ' ' && buffer[*i] != '\t' && buffer[*i] != '\n' &&
	    buffer[*i] != '\r' && buffer[*i] != '>' && buffer[*i] != '/')

		return;

	if ((length = *i - *last) > 0)
		cache_append(cache, buffer + *last, encoding, length);

	pool = [[OFAutoreleasePool alloc] init];

602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
	OFAutoreleasePool *pool;
	const char *cacheCString, *tmp;
	size_t length, cacheLength;
	OFString *cacheString;
	OFString *ns;

	if (buffer[*i] != ' ' && buffer[*i] != '\t' && buffer[*i] != '\n' &&
	    buffer[*i] != '\r' && buffer[*i] != '\f' && buffer[*i] != '>')
		return;

	if ((length = *i - *last) > 0)
		cache_append(cache, buffer + *last, encoding, length);

	pool = [[OFAutoreleasePool alloc] init];








|







600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
	OFAutoreleasePool *pool;
	const char *cacheCString, *tmp;
	size_t length, cacheLength;
	OFString *cacheString;
	OFString *ns;

	if (buffer[*i] != ' ' && buffer[*i] != '\t' && buffer[*i] != '\n' &&
	    buffer[*i] != '\r' && buffer[*i] != '>')
		return;

	if ((length = *i - *last) > 0)
		cache_append(cache, buffer + *last, encoding, length);

	pool = [[OFAutoreleasePool alloc] init];

673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
	OFAutoreleasePool *pool;
	OFString *ns;
	OFXMLAttribute **attributesCArray;
	size_t j, attributesCount;

	if (buffer[*i] != '>' && buffer[*i] != '/') {
		if (buffer[*i] != ' ' && buffer[*i] != '\t' &&
		    buffer[*i] != '\n' && buffer[*i] != '\r' &&
		    buffer[*i] != '\f') {
			*last = *i;
			state = OF_XMLPARSER_IN_ATTR_NAME;
			(*i)--;
		}

		return;
	}







|
<







671
672
673
674
675
676
677
678

679
680
681
682
683
684
685
	OFAutoreleasePool *pool;
	OFString *ns;
	OFXMLAttribute **attributesCArray;
	size_t j, attributesCount;

	if (buffer[*i] != '>' && buffer[*i] != '/') {
		if (buffer[*i] != ' ' && buffer[*i] != '\t' &&
		    buffer[*i] != '\n' && buffer[*i] != '\r') {

			*last = *i;
			state = OF_XMLPARSER_IN_ATTR_NAME;
			(*i)--;
		}

		return;
	}
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
- (void)_parseExpectDelimiterWithBuffer: (const char*)buffer
				      i: (size_t*)i
				   last: (size_t*)last
{
	*last = *i + 1;

	if (buffer[*i] == ' ' || buffer[*i] == '\t' || buffer[*i] == '\n' ||
	    buffer[*i] == '\r' || buffer[*i] == '\f')
		return;

	if (buffer[*i] != '\'' && buffer[*i] != '"')
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];

	delimiter = buffer[*i];







|







787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
- (void)_parseExpectDelimiterWithBuffer: (const char*)buffer
				      i: (size_t*)i
				   last: (size_t*)last
{
	*last = *i + 1;

	if (buffer[*i] == ' ' || buffer[*i] == '\t' || buffer[*i] == '\n' ||
	    buffer[*i] == '\r')
		return;

	if (buffer[*i] != '\'' && buffer[*i] != '"')
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];

	delimiter = buffer[*i];
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
					 i: (size_t*)i
				      last: (size_t*)last
{
	if (buffer[*i] == '>') {
		*last = *i + 1;
		state = OF_XMLPARSER_OUTSIDE_TAG;
	} else if (buffer[*i] != ' ' && buffer[*i] != '\t' &&
	    buffer[*i] != '\n' && buffer[*i] != '\r' && buffer[*i] != '\f')
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];
}

/* In <! */
- (void)_parseInExclamationMarkWithBuffer: (const char*)buffer
					i: (size_t*)i







|







864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
					 i: (size_t*)i
				      last: (size_t*)last
{
	if (buffer[*i] == '>') {
		*last = *i + 1;
		state = OF_XMLPARSER_OUTSIDE_TAG;
	} else if (buffer[*i] != ' ' && buffer[*i] != '\t' &&
	    buffer[*i] != '\n' && buffer[*i] != '\r')
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];
}

/* In <! */
- (void)_parseInExclamationMarkWithBuffer: (const char*)buffer
					i: (size_t*)i
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
/* In <!DOCTYPE ...> */
- (void)_parseInDoctypeWithBuffer: (const char*)buffer
				i: (size_t*)i
			     last: (size_t*)last
{
	if ((level < 6 && buffer[*i] != "OCTYPE"[level]) ||
	    (level == 6 && buffer[*i] != ' ' && buffer[*i] != '\t' &&
	    buffer[*i] != '\n' && buffer[*i] != '\r' && buffer[*i] != '\f'))
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];

	if (level < 7 || buffer[*i] == '<')
		level++;

	if (buffer[*i] == '>') {







|







1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
/* In <!DOCTYPE ...> */
- (void)_parseInDoctypeWithBuffer: (const char*)buffer
				i: (size_t*)i
			     last: (size_t*)last
{
	if ((level < 6 && buffer[*i] != "OCTYPE"[level]) ||
	    (level == 6 && buffer[*i] != ' ' && buffer[*i] != '\t' &&
	    buffer[*i] != '\n' && buffer[*i] != '\r'))
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];

	if (level < 7 || buffer[*i] == '<')
		level++;

	if (buffer[*i] == '>') {