ObjFW  Diff

Differences From Artifact [281bdc699b]:

To Artifact [4c8969afe8]:


175
176
177
178
179
180
181
182

183
184
185
186

187
188
189

190
191
192

193
194
195
196
197
198
199
175
176
177
178
179
180
181

182
183
184
185

186
187
188

189
190
191

192
193
194
195
196
197
198
199







-
+



-
+


-
+


-
+







}

- (void)setPathComponents: (OFArray *)components
{
	void *pool = objc_autoreleasePoolPush();

	if (components == nil) {
		[self setPath: nil];
		self.path = nil;
		return;
	}

	if ([components count] == 0)
	if (components.count == 0)
		@throw [OFInvalidFormatException exception];

	if ([[components firstObject] length] != 0)
	if ([components.firstObject length] != 0)
		@throw [OFInvalidFormatException exception];

	[self setPath: [components componentsJoinedByString: @"/"]];
	self.path = [components componentsJoinedByString: @"/"];

	objc_autoreleasePoolPop(pool);
}

- (void)setQuery: (OFString *)query
{
	void *pool = objc_autoreleasePoolPush();
267
268
269
270
271
272
273
274

275
276
277

278
279
280

281
282
283
284
285
286


287
288
289

290
291
292
293
294
295
296

297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313

314
315
316
317
318
319
320
321
322
323
324
325
267
268
269
270
271
272
273

274
275
276

277
278
279

280
281
282
283
284


285
286
287
288

289
290
291
292
293
294
295

296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312

313
314
315
316
317
318
319
320
321
322
323
324
325







-
+


-
+


-
+




-
-
+
+


-
+






-
+
















-
+












		return;

	pool = objc_autoreleasePoolPush();

	array = [[[_URLEncodedPath
	    componentsSeparatedByString: @"/"] mutableCopy] autorelease];

	if ([[array firstObject] length] != 0)
	if ([array.firstObject length] != 0)
		@throw [OFInvalidFormatException exception];

	endsWithEmpty = ([[array lastObject] length] == 0);
	endsWithEmpty = ([array.lastObject length] == 0);

	while (!done) {
		size_t length = [array count];
		size_t length = array.count;

		done = true;

		for (size_t i = 0; i < length; i++) {
			id object = [array objectAtIndex: i];
			id parent =
			OFString *current = [array objectAtIndex: i];
			OFString *parent =
			    (i > 0 ? [array objectAtIndex: i - 1] : nil);

			if ([object isEqual: @"."] || [object length] == 0) {
			if ([current isEqual: @"."] || current.length == 0) {
				[array removeObjectAtIndex: i];

				done = false;
				break;
			}

			if ([object isEqual: @".."] && parent != nil &&
			if ([current isEqual: @".."] && parent != nil &&
			    ![parent isEqual: @".."]) {
				[array removeObjectsInRange:
				    of_range(i - 1, 2)];

				done = false;
				break;
			}
		}
	}

	[array insertObject: @""
		    atIndex: 0];
	if (endsWithEmpty)
		[array addObject: @""];

	path = [array componentsJoinedByString: @"/"];
	if ([path length] == 0)
	if (path.length == 0)
		path = @"/";

	[self setURLEncodedPath: path];

	objc_autoreleasePoolPop(pool);
}

- (void)makeImmutable
{
	object_setClass(self, [OFURL class]);
}
@end