Subversion Repositories Tewi

Rev

Rev 64 | Rev 70 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 64 Rev 69
Line 1... Line 1...
1
/* $Id: http.c 64 2024-09-18 20:58:17Z nishi $ */
1
/* $Id: http.c 69 2024-09-19 07:44:13Z nishi $ */
2
 
2
 
3
#define SOURCE
3
#define SOURCE
4
 
4
 
5
#include "../config.h"
5
#include "../config.h"
6
 
6
 
Line 295... Line 295...
295
			free(tmp);
295
			free(tmp);
296
		}
296
		}
297
	}
297
	}
298
	free(req->path);
298
	free(req->path);
299
	req->path = result;
299
	req->path = result;
-
 
300
 
-
 
301
	int incr = 0;
-
 
302
	char* p = malloc(1);
-
 
303
	p[0] = 0;
-
 
304
	int j;
-
 
305
	for(j = 0;; j++) {
-
 
306
		if(req->path[j] == '/' || req->path[j] == 0) {
-
 
307
			char oldc = req->path[j];
-
 
308
			cbuf[0] = oldc;
-
 
309
			req->path[j] = 0;
-
 
310
 
-
 
311
			char* pth = req->path + incr;
-
 
312
 
-
 
313
			if(strcmp(pth, "..") == 0) {
-
 
314
				int k;
-
 
315
				if(p[strlen(p) - 1] == '/') p[strlen(p) - 1] = 0;
-
 
316
				for(k = strlen(p) - 1; k >= 0; k--) {
-
 
317
					if(p[k] == '/') {
-
 
318
						p[k + 1] = 0;
-
 
319
						break;
-
 
320
					}
-
 
321
				}
-
 
322
				if(strlen(p) == 0) {
-
 
323
					free(p);
-
 
324
					p = cm_strdup("/");
-
 
325
				}
-
 
326
			} else if(strcmp(pth, ".") == 0) {
-
 
327
			} else if(oldc != '\\') {
-
 
328
				char* tmp = p;
-
 
329
				p = cm_strcat3(tmp, pth, cbuf);
-
 
330
				free(tmp);
-
 
331
			}
-
 
332
 
-
 
333
			incr = j + 1;
-
 
334
			if(oldc == 0) break;
-
 
335
		}
-
 
336
	}
-
 
337
	free(req->path);
-
 
338
	req->path = p;
300
	return 0;
339
	return 0;
301
}
340
}