threads / discuss / 5887

Gitweb indentation wrong in Internet Explorer

Subject: Gitweb indentation wrong in Internet Explorer

## tl;dr

16 messages between Oct 11, 2006 and Oct 13, 2006.

replies: 15people: 5as markdown or json

Ralf Baechle· Oct 11, 2006, 17:25 UTC · lore
I have a report from an MSIE suffering user:
> When I use it (and I believe I've seen this on my laptop as well as my
> workstation) all left-hand margin whitespace is collapsed to nothingness.
> Once can still parse the code, but it's harder with no indentations.

A screenshot from a Windows laptop to illustrate the problem is at http://www.linux-mips.org/~ralf/gitweb.png. It shows the code was preformatted correctly which seems to be an IE bug but the following patch seems to work around it.

*** gitweb.cgi.dist	2006-10-09 19:02:19.561726255 +0100
--- gitweb.cgi	2006-10-09 19:03:31.744837495 +0100
***************
*** 234,239 ****
--- 234,240 ----
  	my $str = shift;
  	$str = decode("utf8", $str, Encode::FB_DEFAULT);
  	$str = escapeHTML($str);
+ 	$str =~ s/ / /g;
  	return $str;
  }
Thanks,
  Ralf  
Jakub Narebski· Oct 11, 2006, 17:47 UTC · re: Ralf Baechle · lore

Re: Gitweb indentation wrong in Internet Explorer

Ralf Baechle wrote:
Show 10 quoted lines
> I have a report from an MSIE suffering user:
> 
>> When I use it (and I believe I've seen this on my laptop as well as my
>> workstation) all left-hand margin whitespace is collapsed to nothingness.
>> Once can still parse the code, but it's harder with no indentations.
> 
> A screenshot from a Windows laptop to illustrate the problem is at
> http://www.linux-mips.org/~ralf/gitweb.png.  It shows the code was
> preformatted correctly which seems to be an IE bug but the following patch
> seems to work around it.

Which version of gitweb? We have removed s/ / /g; in esc_html subroutine in favor of using "white-space: pre;" in CSS some time ago, and we have added escaping FORM FEED and ESCAPE characters.

Could you send git patches, by the way? Or at least '-p' diffs?
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Ralf Baechle· Oct 11, 2006, 18:15 UTC · re: Jakub Narebski · lore

Re: Gitweb indentation wrong in Internet Explorer

On Wed, Oct 11, 2006 at 07:47:24PM +0200, Jakub Narebski wrote:
Show 12 quoted lines
> >> When I use it (and I believe I've seen this on my laptop as well as my
> >> workstation) all left-hand margin whitespace is collapsed to nothingness.
> >> Once can still parse the code, but it's harder with no indentations.
> > 
> > A screenshot from a Windows laptop to illustrate the problem is at
> > http://www.linux-mips.org/~ralf/gitweb.png.  It shows the code was
> > preformatted correctly which seems to be an IE bug but the following patch
> > seems to work around it.
> 
> Which version of gitweb? We have removed s/ / /g; in esc_html
> subroutine in favor of using "white-space: pre;" in CSS some time ago,
> and we have added escaping FORM FEED and ESCAPE characters.

Anything since since at least June 19 seems affected, including yesterday's version.

> Could you send git patches, by the way? Or at least '-p' diffs?
Nope.  I'm just forwarding this.
  Ralf
Pazu· Oct 11, 2006, 20:53 UTC · re: Jakub Narebski · lore

Re: Gitweb indentation wrong in Internet Explorer

Jakub Narebski wrote:
> Which version of gitweb? We have removed s/ / /g; in esc_html
> subroutine in favor of using "white-space: pre;" in CSS some time ago,
> and we have added escaping FORM FEED and ESCAPE characters.

The problem here is that "white-space: pre" is only supported by IE6 in standards compliance mode[1], but the DTD declaration for this page:

<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

surprisingly triggers IE6 quirks mode[2]. A quick fix to this problem would be changing the doctype declaration to use XHTML 1.0 Transitional instead of Strict, as that would trigger IE6 standards-compliance mode.

[1] http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/whitespace.asp

[2] http://hsivonen.iki.fi/doctype/
-- Marcus
Pazu· Oct 11, 2006, 21:13 UTC · re: Pazu · lore

[PATCH] Removes the <?xml?> declaration from gitweb.pl

The XML declaration forces IE6 into quirks mode, breaking our
nice standards compliant stylesheet.
Signed-off-by: Marcus Brito <pazu@pazu.com.br>
---
  gitweb/gitweb.perl |    1 -
  1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 0ec1eef..ecb3b66 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1357,7 +1357,6 @@ sub git_header_html {
     print $cgi->header(-type=>$content_type, -charset => 'utf-8',
                        -status=> $status, -expires => $expires);
     print <<EOF;
-<?xml version="1.0" encoding="utf-8"?>
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
  <!-- git web interface version $version, (C) 2005-2006, Kay Sievers 
<kay.sievers\@vrfy.org>, Christian Gierke -->
-- 
1.4.2.3
Jakub Narebski· Oct 11, 2006, 21:27 UTC · re: Pazu · lore

Re: [PATCH] Removes the <?xml?> declaration from gitweb.pl

Pazu wrote:
> The XML declaration forces IE6 into quirks mode, breaking our
> nice standards compliant stylesheet.
But isn't it _required_ by XML/XHTML?
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Pazu· Oct 12, 2006, 00:26 UTC · re: Jakub Narebski · lore

Re: [PATCH] Removes the <?xml?> declaration from gitweb.pl

Jakub Narebski wrote:
>> The XML declaration forces IE6 into quirks mode, breaking our
>> nice standards compliant stylesheet.
> 
> But isn't it _required_ by XML/XHTML?

As far as I know, it isn't. But even if the specs required it, none of the popular browsers do, and since we're talking about a web page intended for presentation (as opposed to automated data processing), that's what matters.

-- Marcus
Pazu· Oct 12, 2006, 01:08 UTC · re: Jakub Narebski · lore

Re: [PATCH] Removes the <?xml?> declaration from gitweb.pl

Jakub Narebski wrote:
> But isn't it _required_ by XML/XHTML?
According to the XML 1.0 specification, section 2.8:

[Definition: XML documents should begin with a XML declaration which specifies the version of XML being used]

I believe that the use of 'should' instead of 'must' here makes it highly recommended, but not strictly required. Anyway, the comments in my previous message (the 'browser support is what really matters' part) remain valid.

-- Marcus
Robin Rosenberg· Oct 12, 2006, 05:45 UTC · re: Jakub Narebski · lore

Re: [PATCH] Removes the <?xml?> declaration from gitweb.pl

onsdag 11 oktober 2006 23:27 skrev Jakub Narebski:
Show 5 quoted lines
> Pazu wrote:
> > The XML declaration forces IE6 into quirks mode, breaking our
> > nice standards compliant stylesheet.
>
> But isn't it _required_ by XML/XHTML?

For pure XML document it is required, but not for XHTML, unless the encoding is something other than UTF-8 or (shudder) UTF-16. W3C recommends it though.

-- robin
Jakub Narebski· Oct 12, 2006, 21:21 UTC · re: Robin Rosenberg · lore

Re: [PATCH] Removes the <?xml?> declaration from gitweb.pl

Robin Rosenberg wrote:
Show 9 quoted lines
> onsdag 11 oktober 2006 23:27 skrev Jakub Narebski:
> > Pazu wrote:
> > > The XML declaration forces IE6 into quirks mode, breaking our
> > > nice standards compliant stylesheet.
> >
> > But isn't it _required_ by XML/XHTML?
> 
> For pure XML document it is required, but not for XHTML, unless the encoding 
> is something other than UTF-8 or (shudder) UTF-16. W3C recommends it though.

So what should be our decision? Honor IE quirks ;-) and either remove XML declaration, or use Transitional DTD? Add back SPC to &nbsp; conversion in esc_html? Ignore broken browsers?

-- 
Jakub Narebski
Poland
Pazu· Oct 13, 2006, 13:01 UTC · re: Jakub Narebski · lore

Re: [PATCH] Removes the <?xml?> declaration from gitweb.pl

Jakub Narebski wrote:
> So what should be our decision? Honor IE quirks ;-) and either remove
> XML declaration, or use Transitional DTD? Add back SPC to &nbsp; conversion
> in esc_html? Ignore broken browsers?

My bad here. In my first email I said that using the Transitional DTD would fix the problem, but I was wrong. It doesn't matter the DTD you use, if you add a <?xml?> declaration, IE will get it wrong and activate quirks mode.

-- Marcus
Jakub Narebski· Oct 13, 2006, 13:07 UTC · re: Pazu · lore

Re: [PATCH] Removes the <?xml?> declaration from gitweb.pl

Pazu wrote:
Show 10 quoted lines
> Jakub Narebski wrote:
> 
>> So what should be our decision? Honor IE quirks ;-) and either remove
>> XML declaration, or use Transitional DTD? Add back SPC to &nbsp; conversion
>> in esc_html? Ignore broken browsers?
> 
> My bad here. In my first email I said that using the Transitional DTD 
> would fix the problem, but I was wrong. It doesn't matter the DTD you 
> use, if you add a <?xml?> declaration, IE will get it wrong and activate 
> quirks mode.

Well, there is yet another solution. Do browser detection, and do not output <?xml ... ?> declaration for IE. Perhaps that would be best solution.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Pazu· Oct 13, 2006, 14:09 UTC · re: Jakub Narebski · lore

Re: [PATCH] Removes the <?xml?> declaration from gitweb.pl

Jakub Narebski wrote:
> Well, there is yet another solution. Do browser detection, and do not output
> <?xml ... ?> declaration for IE. Perhaps that would be best solution.

Well, there's now drawback in removing the XML declaration (no browser requires it), so why even worry about browser detection?

-- Marcus
Robin Rosenberg· Oct 13, 2006, 14:05 UTC · re: Jakub Narebski · lore

Re: [PATCH] Removes the <?xml?> declaration from gitweb.pl

torsdag 12 oktober 2006 23:21 skrev Jakub Narebski:
Show 15 quoted lines
> Robin Rosenberg wrote:
> > onsdag 11 oktober 2006 23:27 skrev Jakub Narebski:
> > > Pazu wrote:
> > > > The XML declaration forces IE6 into quirks mode, breaking our
> > > > nice standards compliant stylesheet.
> > >
> > > But isn't it _required_ by XML/XHTML?
> >
> > For pure XML document it is required, but not for XHTML, unless the
> > encoding is something other than UTF-8 or (shudder) UTF-16. W3C
> > recommends it though.
>
> So what should be our decision? Honor IE quirks ;-) and either remove
> XML declaration, or use Transitional DTD? Add back SPC to &nbsp; conversion
> in esc_html? Ignore broken browsers?
It isn't required by the standard. Why not just drop it?
-- robin
Jakub Narebski· Oct 13, 2006, 15:09 UTC · re: Robin Rosenberg · lore

Re: [PATCH] Removes the <?xml?> declaration from gitweb.pl

Robin Rosenberg wrote:
Show 18 quoted lines
> torsdag 12 oktober 2006 23:21 skrev Jakub Narebski:
>> Robin Rosenberg wrote:
>>> onsdag 11 oktober 2006 23:27 skrev Jakub Narebski:
>>>> Pazu wrote:
>>>>> The XML declaration forces IE6 into quirks mode, breaking our
>>>>> nice standards compliant stylesheet.
>>>>
>>>> But isn't it _required_ by XML/XHTML?
>>>
>>> For pure XML document it is required, but not for XHTML, unless the
>>> encoding is something other than UTF-8 or (shudder) UTF-16. W3C
>>> recommends it though.
>>
>> So what should be our decision? Honor IE quirks ;-) and either remove
>> XML declaration, or use Transitional DTD? Add back SPC to &nbsp; conversion
>> in esc_html? Ignore broken browsers?
> 
> It isn't required by the standard. Why not just drop it?
>From http://www.w3.org/TR/xhtml1/#docconf
 An XML declaration is not required in all XML documents; however XHTML
 document authors are strongly encouraged to use XML declarations in all
 their documents. Such a declaration is required when the character
 encoding of the document is other than the default UTF-8 or UTF-16 and
 no encoding was determined by a higher-level protocol.

So even if it is not required, it is recommended. But yes, removing <?xml?> for bug-compatibility conformance is better idea than mucking with browser detection... if we sould need browser detection to avoid other bugs (like non-W3C CSS box model in IE), then perhaps we could reintroduce <?xml?> in standards-conforming browsers.

-- 
Jakub Narebski
Poland
Luben Tuikov· Oct 11, 2006, 18:13 UTC · re: Ralf Baechle · lore

Re: Gitweb indentation wrong in Internet Explorer

--- Ralf Baechle <ralf@linux-mips.org> wrote:
Show 10 quoted lines
> I have a report from an MSIE suffering user:
> 
> > When I use it (and I believe I've seen this on my laptop as well as my
> > workstation) all left-hand margin whitespace is collapsed to nothingness.
> > Once can still parse the code, but it's harder with no indentations.
> 
> A screenshot from a Windows laptop to illustrate the problem is at
> http://www.linux-mips.org/~ralf/gitweb.png.  It shows the code was
> preformatted correctly which seems to be an IE bug but the following patch
> seems to work around it.
Thank you.
Has anyone let MSIE people know about this bug?  Or tried latest MSIE?
   Luben
Show 21 quoted lines
> 
> *** gitweb.cgi.dist	2006-10-09 19:02:19.561726255 +0100
> --- gitweb.cgi	2006-10-09 19:03:31.744837495 +0100
> ***************
> *** 234,239 ****
> --- 234,240 ----
>   	my $str = shift;
>   	$str = decode("utf8", $str, Encode::FB_DEFAULT);
>   	$str = escapeHTML($str);
> + 	$str =~ s/ /&nbsp;/g;
>   	return $str;
>   }
> 
> Thanks,
> 
>   Ralf  
> -
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

← back to recent threads