Project

General

Profile

patch01_dirlisting_option_noescape.patch

Patch 1: Adds an option that disables escaping - penma, 2009-09-06 11:08

View differences:

src/mod_dirlisting.c
56 56
	unsigned short hide_dot_files;
57 57
	unsigned short show_readme;
58 58
	unsigned short hide_readme_file;
59
	unsigned short escape_readme;
59 60
	unsigned short show_header;
60 61
	unsigned short hide_header_file;
62
	unsigned short escape_header;
61 63

  
62 64
	excludes_buffer *excludes;
63 65

  
......
248 250
#define CONFIG_ENCODING         "dir-listing.encoding"
249 251
#define CONFIG_SHOW_README      "dir-listing.show-readme"
250 252
#define CONFIG_HIDE_README_FILE "dir-listing.hide-readme-file"
253
#define CONFIG_ESCAPE_README    "dir-listing.escape-readme"
251 254
#define CONFIG_SHOW_HEADER      "dir-listing.show-header"
252 255
#define CONFIG_HIDE_HEADER_FILE "dir-listing.hide-header-file"
256
#define CONFIG_ESCAPE_HEADER    "dir-listing.escape-header"
253 257
#define CONFIG_DIR_LISTING      "server.dir-listing"
254 258
#define CONFIG_SET_FOOTER       "dir-listing.set-footer"
255 259

  
......
266 270
		{ CONFIG_ENCODING,         NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },  /* 4 */
267 271
		{ CONFIG_SHOW_README,      NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 5 */
268 272
		{ CONFIG_HIDE_README_FILE, NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 6 */
269
		{ CONFIG_SHOW_HEADER,      NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 7 */
270
		{ CONFIG_HIDE_HEADER_FILE, NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 8 */
271
		{ CONFIG_DIR_LISTING,      NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 9 */
272
		{ CONFIG_SET_FOOTER,       NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 10 */
273
		{ CONFIG_ESCAPE_README,    NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 7 */
274
		{ CONFIG_SHOW_HEADER,      NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 8 */
275
		{ CONFIG_HIDE_HEADER_FILE, NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 9 */
276
		{ CONFIG_ESCAPE_HEADER,    NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 10 */
277
		{ CONFIG_DIR_LISTING,      NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 11 */
278
		{ CONFIG_SET_FOOTER,       NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },  /* 12 */
273 279

  
274 280
		{ NULL,                          NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
275 281
	};
......
289 295
		s->hide_dot_files = 0;
290 296
		s->show_readme = 0;
291 297
		s->hide_readme_file = 0;
298
		s->escape_readme = 1;
292 299
		s->show_header = 0;
293 300
		s->hide_header_file = 0;
301
		s->escape_header = 1;
294 302
		s->encoding = buffer_init();
295 303
		s->set_footer = buffer_init();
296 304

  
......
301 309
		cv[4].destination = s->encoding;
302 310
		cv[5].destination = &(s->show_readme);
303 311
		cv[6].destination = &(s->hide_readme_file);
304
		cv[7].destination = &(s->show_header);
305
		cv[8].destination = &(s->hide_header_file);
306
		cv[9].destination = &(s->dir_listing); /* old name */
307
		cv[10].destination = s->set_footer;
312
		cv[7].destination = &(s->escape_readme);
313
		cv[8].destination = &(s->show_header);
314
		cv[9].destination = &(s->hide_header_file);
315
		cv[10].destination = &(s->escape_header);
316
		cv[11].destination = &(s->dir_listing); /* old name */
317
		cv[12].destination = s->set_footer;
308 318

  
309 319
		p->config_storage[i] = s;
310 320
		ca = ((data_config *)srv->config_context->data[i])->value;
......
329 339
	PATCH_OPTION(encoding);
330 340
	PATCH_OPTION(show_readme);
331 341
	PATCH_OPTION(hide_readme_file);
342
	PATCH_OPTION(escape_readme);
332 343
	PATCH_OPTION(show_header);
333 344
	PATCH_OPTION(hide_header_file);
345
	PATCH_OPTION(escape_header);
334 346
	PATCH_OPTION(excludes);
335 347
	PATCH_OPTION(set_footer);
336 348

  
......
359 371
				PATCH_OPTION(show_readme);
360 372
			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_HIDE_README_FILE))) {
361 373
				PATCH_OPTION(hide_readme_file);
374
			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_ESCAPE_README))) {
375
				PATCH_OPTION(escape_readme);
362 376
			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_SHOW_HEADER))) {
363 377
				PATCH_OPTION(show_header);
364 378
			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_HIDE_HEADER_FILE))) {
365 379
				PATCH_OPTION(hide_header_file);
380
			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_ESCAPE_HEADER))) {
381
				PATCH_OPTION(escape_header);
366 382
			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_SET_FOOTER))) {
367 383
				PATCH_OPTION(set_footer);
368 384
			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_EXCLUDE))) {
......
522 538
		buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("HEADER.txt"));
523 539

  
524 540
		if (-1 != stream_open(&s, p->tmp_buf)) {
525
			buffer_append_string_len(out, CONST_STR_LEN("<pre class=\"header\">"));
526
			buffer_append_string_encoded(out, s.start, s.size, ENCODING_MINIMAL_XML);
527
			buffer_append_string_len(out, CONST_STR_LEN("</pre>"));
541
			if (p->conf.escape_header) {
542
				buffer_append_string_len(out, CONST_STR_LEN("<pre class=\"header\">"));
543
				buffer_append_string_encoded(out, s.start, s.size, ENCODING_MINIMAL_XML);
544
				buffer_append_string_len(out, CONST_STR_LEN("</pre>"));
545
			} else {
546
				buffer_append_string_len(out, s.start, s.size);
547
			}
528 548
		}
529 549
		stream_close(&s);
530 550
	}
......
571 591
		buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("README.txt"));
572 592

  
573 593
		if (-1 != stream_open(&s, p->tmp_buf)) {
574
			buffer_append_string_len(out, CONST_STR_LEN("<pre class=\"readme\">"));
575
			buffer_append_string_encoded(out, s.start, s.size, ENCODING_MINIMAL_XML);
576
			buffer_append_string_len(out, CONST_STR_LEN("</pre>"));
594
			if (p->conf.escape_readme) {
595
				buffer_append_string_len(out, CONST_STR_LEN("<pre class=\"readme\">"));
596
				buffer_append_string_encoded(out, s.start, s.size, ENCODING_MINIMAL_XML);
597
				buffer_append_string_len(out, CONST_STR_LEN("</pre>"));
598
			} else {
599
				buffer_append_string_len(out, s.start, s.size);
600
			}
577 601
		}
578 602
		stream_close(&s);
579 603
	}
580
-