ObjFW  Check-in [1efd40d895]

Overview
Comment:OFXMLParser: Require version in prolog.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1efd40d895d246861443c33daf9aae849e33894ac07524c93eb3be957b28d81b
User & Date: js on 2013-04-10 16:48:17
Other Links: manifest | tags
Context
2013-04-10
20:56
OFHTTPServer: Fix an evil typo. check-in: 9ea5f2723f user: js tags: trunk
16:48
OFXMLParser: Require version in prolog. check-in: 1efd40d895 user: js tags: trunk
2013-04-09
22:09
Fix incomplete of_char16_t migration. check-in: 8fe08864f8 user: js tags: trunk
Changes

Modified src/OFXMLParser.m from [a389df28b8] to [3a91a054b9].

392
393
394
395
396
397
398

399
400
401
402
403
404
405
{
	const char *cString;
	size_t i, last, length;
	int PIState = 0;
	OFString *attribute = nil;
	OFMutableString *value = nil;
	char piDelimiter = 0;


	if (!_acceptProlog)
		return false;

	_acceptProlog = false;

	pi = [pi substringWithRange: of_range(3, [pi length] - 3)];







>







392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
{
	const char *cString;
	size_t i, last, length;
	int PIState = 0;
	OFString *attribute = nil;
	OFMutableString *value = nil;
	char piDelimiter = 0;
	bool hasVersion = false;

	if (!_acceptProlog)
		return false;

	_acceptProlog = false;

	pi = [pi substringWithRange: of_range(3, [pi length] - 3)];
444
445
446
447
448
449
450
451
452
453



454
455
456
457
458
459
460
			if (cString[i] != piDelimiter)
				continue;

			value = [OFMutableString
			    stringWithUTF8String: cString + last
					  length: i - last];

			if ([attribute isEqual: @"version"])
				if (![value hasPrefix: @"1."])
					return false;




			if ([attribute isEqual: @"encoding"]) {
				[value lowercase];

				if ([value isEqual: @"utf-8"])
					_encoding = OF_STRING_ENCODING_UTF_8;
				else if ([value isEqual: @"iso-8859-1"])







|


>
>
>







445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
			if (cString[i] != piDelimiter)
				continue;

			value = [OFMutableString
			    stringWithUTF8String: cString + last
					  length: i - last];

			if ([attribute isEqual: @"version"]) {
				if (![value hasPrefix: @"1."])
					return false;

				hasVersion = true;
			}

			if ([attribute isEqual: @"encoding"]) {
				[value lowercase];

				if ([value isEqual: @"utf-8"])
					_encoding = OF_STRING_ENCODING_UTF_8;
				else if ([value isEqual: @"iso-8859-1"])
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
			last = i + 1;
			PIState = 0;

			break;
		}
	}

	if (PIState != 0)
		return false;

	return true;
}

/* Inside processing instructions */
- (void)OF_parseInProcessingInstructionsWithBuffer: (const char*)buffer







|







477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
			last = i + 1;
			PIState = 0;

			break;
		}
	}

	if (PIState != 0 || !hasVersion)
		return false;

	return true;
}

/* Inside processing instructions */
- (void)OF_parseInProcessingInstructionsWithBuffer: (const char*)buffer