diff --git a/ngx_http_fancyindex_module.c b/ngx_http_fancyindex_module.c index 29c1086..d5f1722 100644 --- a/ngx_http_fancyindex_module.c +++ b/ngx_http_fancyindex_module.c @@ -328,6 +328,7 @@ typedef struct { ngx_str_t name; size_t utf_len; ngx_uint_t escape; + ngx_uint_t escape_html; ngx_uint_t dir; time_t mtime; off_t size; @@ -668,7 +669,7 @@ make_content_buf( const char *sort_url_args = ""; off_t length; - size_t len, root, copy, allocated; + size_t len, root, copy, allocated, escape_html; int64_t multiplier; u_char *filename, *last; ngx_tm_t tm; @@ -832,6 +833,9 @@ make_content_buf( entry->escape = 2 * ngx_fancyindex_escape_filename(NULL, ngx_de_name(&dir), len); + entry->escape_html = ngx_escape_html(NULL, + entry->name.data, + entry->name.len); entry->dir = ngx_de_is_dir(&dir); entry->mtime = ngx_de_mtime(&dir); @@ -850,8 +854,11 @@ make_content_buf( /* * Calculate needed buffer length. */ + + escape_html = ngx_escape_html(NULL, r->uri.data, r->uri.len); + if (alcf->show_path) - len = r->uri.len + len = r->uri.len + escape_html + ngx_sizeof_ssz(t05_body2) + ngx_sizeof_ssz(t06_list1) + ngx_sizeof_ssz(t_parentdir_entry) @@ -859,7 +866,7 @@ make_content_buf( + ngx_fancyindex_timefmt_calc_size (&alcf->time_format) * entries.nelts ; else - len = r->uri.len + len = r->uri.len + escape_html + ngx_sizeof_ssz(t06_list1) + ngx_sizeof_ssz(t_parentdir_entry) + ngx_sizeof_ssz(t07_list2) @@ -889,9 +896,9 @@ make_content_buf( + entry[i].name.len + entry[i].escape /* Escaped URL */ + ngx_sizeof_ssz("?C=x&O=y") /* URL sorting arguments */ + ngx_sizeof_ssz("\" title=\"") - + entry[i].name.len + entry[i].utf_len + + entry[i].name.len + entry[i].utf_len + entry[i].escape_html + ngx_sizeof_ssz("\">") - + entry[i].name.len + entry[i].utf_len + + entry[i].name.len + entry[i].utf_len + entry[i].escape_html + alcf->name_length + ngx_sizeof_ssz(">") + ngx_sizeof_ssz("