This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Fix HTML produced by http.server
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.3
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ezio.melotti Nosy List: eric.araujo, ezio.melotti, karlcow, loewis, orsenthil, python-dev
Priority: normal Keywords: patch

Created on 2011-10-30 15:07 by karlcow, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
server-html5.patch karlcow, 2011-10-30 15:07
issue13295.diff ezio.melotti, 2011-10-30 16:25 review
issue13295-2.diff ezio.melotti, 2011-10-31 18:53 review
Messages (14)
msg146641 - (view) Author: karl (karlcow) * Date: 2011-10-30 15:07
The code has a set of old HTML templates. Here is a patch to change it to very simple html5 templates.
msg146643 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-10-30 16:12
I think HTML 4.01 strict is still fine -- no need to move to HTML 5 yet.
The template that uses HTML 3.2 can probably be updated though.
msg146644 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-10-30 16:25
Here's a patch to replace 3.2 with 4.01.
The output of the page should be checked and validated before committing this.
I'm not sure if this should go in 2.7/3.2 too, on one hand it's not a bug fix so it shouldn't, on the other hand I don't think it will break anything and it's consistent with the doctype used for the error page.
msg146658 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2011-10-30 20:41
Ezio: your patch is fine for 3.3. I agree it's not a bug fix.
I propose the following additional changes, though:
- the name of the root element should be lower-case in the DOCTYPE declaration.
- DEFAULT_ERROR_MESSAGE should get an opening html tag.

karl: HTML 3.2 may be old, but it's not outdated.
msg146697 - (view) Author: karl (karlcow) * Date: 2011-10-31 15:05
Ezio, Martin, 

HTML 3.2, HTML 4.01 are not outdated. They have stable specifications. That said their doctypes have not influence at all in browsers. The html5 doctype <!DOCTYPE html> has been chosen because it was the minimal string of characters that put the browsers into strict mode rendering (See Quirks Mode in CSS). The W3C validator is the only tool implementing an SGML parser able to understand HTML 3.2 and HTML 4.01. Note also that the W3C validtor includes an html5 validator if the concern is the validity of the output.
msg146701 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-10-31 15:13
My point is that the HTML5 doctype doesn't bring us anything (except maybe a shorter string), so I don't see the point of changing it.
When the HTML5 spec is stable we can switch to it, but even then the update won't change anything.
msg146703 - (view) Author: karl (karlcow) * Date: 2011-10-31 15:35
Yup. I doesn't bring anything except putting the output in line with the reality of browsers implementations. You may close it. I don't mind.
msg146704 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-10-31 16:08
I’d rather fix the page (look at the diff to find one violation: the first heading is an h2 instead of h1) and use an HTML5 doctype, as it’s just HTML 4.01 + pragmatism.
msg146715 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2011-10-31 17:05
I declare the original issue closed - there is no reason to switch to HTML 5 in this code.

There are side issues, such as the HTML 3.2 perhaps being incorrect; people who want to commit patches in that respect can just go ahead.
msg146718 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-10-31 17:15
msg146729 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-10-31 18:53
Attached patch updates the pages to pass the validation, use HTML 4.01 and specify the encoding of the page in the <meta> tag.
msg146850 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-11-02 16:58
Thanks.  +0.
msg146855 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-11-02 17:33
New changeset 10823e7be085 by Ezio Melotti in branch 'default':
#13295: http.server now produces valid HTML 4.01 strict.
msg146856 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-11-02 17:35
Fixed, thanks for the report and the reviews!
Date User Action Args
2022-04-11 14:57:23adminsetgithub: 57504
2011-11-02 17:35:26ezio.melottisetstatus: open -> closed
resolution: fixed
messages: + msg146856

stage: commit review -> resolved
2011-11-02 17:33:56python-devsetnosy: + python-dev
messages: + msg146855
2011-11-02 16:58:45eric.araujosetmessages: + msg146850
2011-10-31 18:53:40ezio.melottisetfiles: + issue13295-2.diff

stage: patch review -> commit review
messages: + msg146729
versions: - Python 2.7, Python 3.2
2011-10-31 17:15:29eric.araujosettitle: html5 template for Lib/http/ -> Fix HTML produced by http.server
messages: + msg146718
versions: + Python 2.7, Python 3.2
2011-10-31 17:05:25loewissetmessages: + msg146715
2011-10-31 16:08:23eric.araujosetmessages: + msg146704
2011-10-31 15:51:37ezio.melottisetassignee: ezio.melotti
stage: patch review
2011-10-31 15:35:53karlcowsetmessages: + msg146703
2011-10-31 15:13:28ezio.melottisetmessages: + msg146701
2011-10-31 15:05:15karlcowsetmessages: + msg146697
2011-10-30 20:41:14loewissetnosy: + loewis
messages: + msg146658
2011-10-30 16:25:08ezio.melottisetfiles: + issue13295.diff

messages: + msg146644
2011-10-30 16:12:51ezio.melottisetnosy: + eric.araujo, ezio.melotti

messages: + msg146643
versions: + Python 3.3, - Python 3.1, Python 3.2
2011-10-30 15:07:24karlcowcreate