ObjFW  Check-in [cc2c113c29]

Overview
Comment:OFDNSResolverSettings: Don't assume UTF-8

Some systems even come by default with non-UTF-8 characters in those
config files. In particular, a German Windows XP uses non-UTF-8 comments
in there by default.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: cc2c113c2970e0d1b66d50a9f848ccf3f8e32abc4338c1cec7afc23378d81588
User & Date: js on 2022-11-03 21:09:34
Other Links: manifest | tags
Context
2022-11-04
20:23
Add support for IPv6 addresses with scope check-in: 027b704b66 user: js tags: trunk
2022-11-03
21:09
OFDNSResolverSettings: Don't assume UTF-8 check-in: cc2c113c29 user: js tags: trunk
00:14
OFDDPSocket: Don't include the type with the data check-in: 9c2f20e736 user: js tags: trunk
Changes

Modified src/OFDNSResolverSettings.m from [27f5b4db4d] to [bdd49f7898].

264
265
266
267
268
269
270

271

272
273
274
275
276
277
278
	} @catch (OFOpenItemFailedException *e) {
		objc_autoreleasePoolPop(pool);
		return;
	}

	staticHosts = [OFMutableDictionary dictionary];


	while ((line = [file readLine]) != nil) {

		OFArray *components, *hosts;
		size_t pos;
		OFString *address;

		pos = [line rangeOfString: @"#"].location;
		if (pos != OFNotFound)
			line = [line substringToIndex: pos];







>
|
>







264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
	} @catch (OFOpenItemFailedException *e) {
		objc_autoreleasePoolPop(pool);
		return;
	}

	staticHosts = [OFMutableDictionary dictionary];

	/* Use ISO 8859-1 to ignore any potential non-UTF-8 comments. */
	while ((line =
	    [file readLineWithEncoding: OFStringEncodingISO8859_1]) != nil) {
		OFArray *components, *hosts;
		size_t pos;
		OFString *address;

		pos = [line rangeOfString: @"#"].location;
		if (pos != OFNotFound)
			line = [line substringToIndex: pos];
364
365
366
367
368
369
370

371

372
373
374
375
376
377
378
		objc_autoreleasePoolPop(pool);
		return;
	}

	if (nameServers == nil)
		nameServers = [OFMutableArray array];


	while ((line = [file readLine]) != nil) {

		void *pool2 = objc_autoreleasePoolPush();
		size_t pos;
		OFArray *components, *arguments;
		OFString *option;

		pos = [line indexOfCharacterFromSet: commentCharacters];
		if (pos != OFNotFound)







>
|
>







366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
		objc_autoreleasePoolPop(pool);
		return;
	}

	if (nameServers == nil)
		nameServers = [OFMutableArray array];

	/* Use ISO 8859-1 to ignore any potential non-UTF-8 comments. */
	while ((line =
	    [file readLineWithEncoding: OFStringEncodingISO8859_1]) != nil) {
		void *pool2 = objc_autoreleasePoolPush();
		size_t pos;
		OFArray *components, *arguments;
		OFString *option;

		pos = [line indexOfCharacterFromSet: commentCharacters];
		if (pos != OFNotFound)