{"thread":{"id":"4820","subject":"[PATCH] gitweb: Send XHTML as 'application/xhtml+xml' where possible","startedAt":"2006-07-09T14:55:21Z","lastAt":"2006-07-09T14:55:21Z","messageCount":1,"participants":["Alp Toker"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"23484","messageId":"11524569211631-git-send-email-alp@atoker.com","threadId":"4820","inReplyTo":null,"subject":"[PATCH] gitweb: Send XHTML as 'application/xhtml+xml' where possible","fromName":"Alp Toker","fromEmail":"alp@atoker.com","sentAt":"2006-07-09T14:55:21Z","receivedAt":"2006-07-09T14:55:21Z","isPatch":true,"sender":{"key":"alp@atoker.com","avatar":"https://gravatar.com/avatar/5367b73f1bb2598314e084847e4f45c303514c7fd192cfa9aa3c3437511567cd?d=mp&s=160"},"body":"\"The 'text/html' media type [RFC2854] is primarily for HTML, not for\nXHTML. In general, this media type is NOT suitable for XHTML.\"\n\nThis patch makes gitweb use content negotiation to conservatively send\npages as Content-Type 'application/xhtml+xml' when the user agent\nexplicitly claims to support it.\n\nIt falls back to 'text/html' even if the user agent appears to\nimplicitly support 'application/xhtml+xml' due to a '*/*' glob, working\naround an insidious bug in Internet Explorer where sending the correct\nmedia type prevents the page from being displayed.\n\nSigned-off-by: Alp Toker <alp@atoker.com>\n---\n gitweb/gitweb.cgi |   14 ++++++++++++--\n 1 files changed, 12 insertions(+), 2 deletions(-)\n\ndiff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi\nindex 3e2790c..beb8061 100755\n--- a/gitweb/gitweb.cgi\n+++ b/gitweb/gitweb.cgi\n@@ -290,7 +290,17 @@ sub git_header_html {\n \t\t\t}\n \t\t}\n \t}\n-\tprint $cgi->header(-type=>'text/html',  -charset => 'utf-8', -status=> $status, -expires => $expires);\n+\tmy $content_type;\n+\t# require explicit support from the UA if we are to send the page as\n+\t# 'application/xhtml+xml', otherwise send it as plain old 'text/html'.\n+\t# we have to do this because MSIE sometimes globs '*/*', pretending to\n+\t# support xhtml+xml but choking when it gets what it asked for.\n+\tif ($cgi->http('HTTP_ACCEPT') =~ m/(,|;|\\s|^)application\\/xhtml\\+xml(,|;|\\s|$)/ && $cgi->Accept('application/xhtml+xml') != 0) {\n+\t\t$content_type = 'application/xhtml+xml';\n+\t} else {\n+\t\t$content_type = 'text/html';\n+\t}\n+\tprint $cgi->header(-type=>$content_type,  -charset => 'utf-8', -status=> $status, -expires => $expires);\n \tprint <<EOF;\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n@@ -298,7 +308,7 @@ sub git_header_html {\n <!-- git web interface v$version, (C) 2005-2006, Kay Sievers <kay.sievers\\@vrfy.org>, Christian Gierke -->\n <!-- git core binaries version $git_version -->\n <head>\n-<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"/>\n+<meta http-equiv=\"content-type\" content=\"$content_type; charset=utf-8\"/>\n <meta name=\"robots\" content=\"index, nofollow\"/>\n <title>$title</title>\n <link rel=\"stylesheet\" type=\"text/css\" href=\"$stylesheet\"/>\n-- \n1.4.1.gbe4c7\n"}]}