Opened 2 years ago

Last modified 17 months ago

#2410 accepted enhancement

Add a doctype to autoindex HTML output

Reported by: doerwalter@… Owned by:
Priority: minor Milestone:
Component: nginx-module Version: 1.19.x
Keywords: Cc:
uname -a: Linux 75d6e5b8ec8f 4.19.0-22-amd64 #1 SMP Debian 4.19.260-1 (2022-09-29) x86_64 Linux
nginx -V: nginx version: nginx/1.23.1
built by gcc 11.2.1 20220219 (Alpine 11.2.1_git20220219)
built with OpenSSL 1.1.1o 3 May 2022 (running with OpenSSL 1.1.1q 5 Jul 2022)
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --with-perl_modules_path=/usr/lib/perl5/vendor_perl --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-Os -fomit-frame-pointer -g' --with-ld-opt=-Wl,--as-needed,-O1,--sort-common

Description

Currently the output of a directory by the autoindex module looks like this:

<html>
<head><title>Index of /jquery/3.6.0/</title></head>
<body>
<h1>Index of /jquery/3.6.0/</h1><hr><pre><a href="../">../</a>
<a href="dist/">dist/</a>                                              30-May-2022 11:52                   -
<a href="external/">external/</a>                                          30-May-2022 11:52                   -
<a href="src/">src/</a>                                               30-May-2022 11:52                   -
<a href="AUTHORS.txt">AUTHORS.txt</a>                                        30-May-2022 11:52               12448
<a href="LICENSE.txt">LICENSE.txt</a>                                        30-May-2022 11:52                1097
<a href="README.md">README.md</a>                                          30-May-2022 11:52                1996
<a href="package.json">package.json</a>                                       30-May-2022 11:52                3027
</pre><hr></body>
</html>

Would it be possible to update the output to be proper HTML5 (including a DOCTYPE)?

The reason for this that we're using a autoindex directory for an additional download source for Python packages. But using PIP 22.0.2 gives the following warning:

DEPRECATION: The HTML index page being used (http://www.example.org/python-downloads/) is not a proper HTML 5 document. This is in violation of PEP 503 which requires these pages to be well-formed HTML 5 documents. Please reach out to the owners of this index page, and ask them to update this index page to a valid HTML 5 document. pip 22.2 will enforce this behaviour change. Discussion can be found at https://github.com/pypa/pip/issues/10825

Change History (2)

comment:1 by Maxim Dounin, 2 years ago

Status: newaccepted

In general it might be beneficial to switch all internally generated HTML documents to HTML5, notably autoindex HTML output and error pages.

In particular, we already use proper HTML5 for default index page and the error template as shipped with nginx (ed470a7bf7fd, b5ba6f22a0fc). Also, error pages and autoindex seems to be mostly compatible with HTML5 since bgcolor was removed (170922952477), though some non-compatible elements are still used (such as <center> in error pages).

Such a change would probably need to be carefully checked to produce similar output in various popular browsers, and at least being readable by various ancient browsers.

Note though that if you need some specific and/or machine-readable output for autoindex, autoindex_format xml; can be used to produce it, along with the XSLT filter module.

comment:2 by Maxim Dounin, 17 months ago

See also #2522.

Note: See TracTickets for help on using tickets.