Bug 56285 - mod_proxy_html removes the <!doctype> tag and breaks XHTML documents
Summary: mod_proxy_html removes the <!doctype> tag and breaks XHTML documents
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_proxy_html (show other bugs)
Version: 2.5-HEAD
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2014-03-19 20:48 UTC by Micha Lenk
Modified: 2014-06-01 21:22 UTC (History)
0 users



Attachments
Let mod_proxy_html keep the doctype and fix empty tag ending in XHTML documents (2.19 KB, patch)
2014-03-19 20:48 UTC, Micha Lenk
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Micha Lenk 2014-03-19 20:48:04 UTC
Created attachment 31408 [details]
Let mod_proxy_html keep the doctype and fix empty tag ending in XHTML documents

Currently mod_proxy_html removes any <!doctype> tags from the beginning of HTML and XHTML documents. This <!doctype> tag is needed by some browsers to correctly render XHTML documents.

Additionally mod_proxy_html doesn't terminate empty tags in XHTML documents correctly unless "ProxyHTMLDoctype XHTML" is explicitly configured. So, unless you have ProxyHTMLDoctype configured correctly, XHTML documents are invalid after passing mod_proxy_html.

The attached patch fixes the first issue by using the internalSubset hook of the libxml2 SAX parser to parse and output the <!doctype> tag. To address the second issue, the same hook is used to automatically detect whether the current document is an XHTML document or not. In case of an XHTML document the XHTML-style for closing empty tags is enabled for the current request. In my opinion the suggested patch makes the directive ProxyHTMLDoctype more or less obsolete. Of course it is kept for backwards compatibility.

The patch is based on httpd trunk, rev. 1579365.
Comment 1 Nick Kew 2014-06-01 17:07:09 UTC
You mean automatic doctype detection?  Dammit, thought I'd done something more-or-less equivalent years ago, but I guess that must've been in another module.  Will check your patch - thanks.
Comment 2 Nick Kew 2014-06-01 21:22:24 UTC
I've adapted your patch a little, and made "auto" a configuration option.  Committed in r1599027 .  Thanks for the patch.