{"thread":{"id":"4818","subject":"[PATCH] gitweb: Send XHTML as 'application/xhtml+xml' where possible","startedAt":"2006-07-09T09:41:58Z","lastAt":"2006-07-09T11:18:12Z","messageCount":3,"participants":["Alp Toker","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"23463","messageId":"11524381182709-git-send-email-alp@atoker.com","threadId":"4818","inReplyTo":null,"subject":"[PATCH] gitweb: Send XHTML as 'application/xhtml+xml' where possible","fromName":"Alp Toker","fromEmail":"alp@atoker.com","sentAt":"2006-07-09T09:41:58Z","receivedAt":"2006-07-09T09:41:58Z","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 claims to support\n'application/xhtml+xml' by means of a glob in order to work around an\ninsidious Internet Explorer bug.\n\nSigned-off-by: Alp Toker <alp@atoker.com>\n---\n gitweb/gitweb.cgi |    5 +++--\n 1 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi\nindex 3e2790c..3206435 100755\n--- a/gitweb/gitweb.cgi\n+++ b/gitweb/gitweb.cgi\n@@ -290,7 +290,8 @@ 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 = ($cgi->http('HTTP_ACCEPT') =~ m/(,|;|\\s|^)application\\/xhtml\\+xml(,|;|\\s|$)/ && $cgi->Accept('application/xhtml+xml') ne 0) ? 'application/xhtml+xml' : 'text/html';\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 +299,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"},{"id":"23472","messageId":"7vwtanm5eb.fsf@assigned-by-dhcp.cox.net","threadId":"4818","inReplyTo":"11524381182709-git-send-email-alp@atoker.com","subject":"Re: [PATCH] gitweb: Send XHTML as 'application/xhtml+xml' where possible","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-07-09T10:36:28Z","receivedAt":"2006-07-09T10:36:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alp Toker <alp@atoker.com> writes:\n\n> \"The 'text/html' media type [RFC2854] is primarily for HTML, not for\n> XHTML. In general, this media type is NOT suitable for XHTML.\"\n>\n> This patch makes gitweb use content negotiation to conservatively send\n> pages as Content-Type 'application/xhtml+xml' when the user agent\n> explicitly claims to support it.\n\nOk.\n\n> It falls back to 'text/html' even if the user agent claims to support\n> 'application/xhtml+xml' by means of a glob in order to work around an\n> insidious Internet Explorer bug.\n\nI do not care much about IE, but...\n\n> +\tmy $content_type = ($cgi->http('HTTP_ACCEPT') =~ m/(,|;|\\s|^)application\\/xhtml\\+xml(,|;|\\s|$)/ && $cgi->Accept('application/xhtml+xml') ne 0) ? 'application/xhtml+xml' : 'text/html';\n\n1. I would prefer something like this to be written with if-else,\n   not with a conditional expression;\n\n2. The \"by means of a glob\" hack needs to be left as a comment\n   in the code to say why;\n\n3. Did you really mean to say \"ne 0\"?\n"},{"id":"23473","messageId":"44B0E5F4.3000604@atoker.com","threadId":"4818","inReplyTo":"7vwtanm5eb.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] gitweb: Send XHTML as 'application/xhtml+xml' where possible","fromName":"Alp Toker","fromEmail":"alp@atoker.com","sentAt":"2006-07-09T11:18:12Z","receivedAt":"2006-07-09T11:18:12Z","isPatch":true,"sender":{"key":"alp@atoker.com","avatar":"https://gravatar.com/avatar/5367b73f1bb2598314e084847e4f45c303514c7fd192cfa9aa3c3437511567cd?d=mp&s=160"},"body":"Junio C Hamano wrote:\n>> It falls back to 'text/html' even if the user agent claims to support\n>> 'application/xhtml+xml' by means of a glob in order to work around an\n>> insidious Internet Explorer bug.\n> \n> I do not care much about IE, but...\n\nThat makes the two of us. Still, it's probably worth not blocking out IE \nin case the need arises to check up on repositories from internet cafes \nwhen on holiday or the like.\n\n>> +\tmy $content_type = ($cgi->http('HTTP_ACCEPT') =~ m/(,|;|\\s|^)application\\/xhtml\\+xml(,|;|\\s|$)/ && $cgi->Accept('application/xhtml+xml') ne 0) ? 'application/xhtml+xml' : 'text/html';\n> \n> 1. I would prefer something like this to be written with if-else,\n>    not with a conditional expression;\n\nIndeed, this line is a bit unwieldy. Will break it out.\n\n> 2. The \"by means of a glob\" hack needs to be left as a comment\n>    in the code to say why;\n\nGood plan.\n\n> 3. Did you really mean to say \"ne 0\"?\n\nWell spotted. String comparison works, but != would be more sensible.\n\nA revised patch is in the works.\n"}]}