# Gitweb indentation wrong in Internet Explorer

16 messages from 2006-10-11 to 2006-10-13. Participants: Ralf Baechle, Jakub Narebski, Luben Tuikov, Pazu, Robin Rosenberg.
Thread: https://gitlist.dev/t/5887

## Ralf Baechle, 2006-10-11 17:25

Subject: Gitweb indentation wrong in Internet Explorer
Message-ID: <20061011172553.GA1147@linux-mips.org>
URL: https://gitlist.dev/e/20061011172553.GA1147%40linux-mips.org

```
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/ /&nbsp;/g;
  	return $str;
  }

Thanks,

  Ralf  

```

## Jakub Narebski, 2006-10-11 17:47

Subject: Re: Gitweb indentation wrong in Internet Explorer
Message-ID: <egjang$nmh$1@sea.gmane.org>
URL: https://gitlist.dev/e/egjang%24nmh%241%40sea.gmane.org
In-Reply-To: <20061011172553.GA1147@linux-mips.org>

```
Ralf Baechle wrote:

> 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/ /&nbsp;/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

```

## Luben Tuikov, 2006-10-11 18:13

Subject: Re: Gitweb indentation wrong in Internet Explorer
Message-ID: <20061011181348.85585.qmail@web31801.mail.mud.yahoo.com>
URL: https://gitlist.dev/e/20061011181348.85585.qmail%40web31801.mail.mud.yahoo.com
In-Reply-To: <20061011172553.GA1147@linux-mips.org>

```
--- Ralf Baechle <ralf@linux-mips.org> wrote:
> 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

> 
> *** 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
> 

```

## Ralf Baechle, 2006-10-11 18:15

Subject: Re: Gitweb indentation wrong in Internet Explorer
Message-ID: <20061011181526.GA13892@linux-mips.org>
URL: https://gitlist.dev/e/20061011181526.GA13892%40linux-mips.org
In-Reply-To: <egjang$nmh$1@sea.gmane.org>

```
On Wed, Oct 11, 2006 at 07:47:24PM +0200, Jakub Narebski wrote:

> >> 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/ /&nbsp;/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, 2006-10-11 20:53

Subject: Re: Gitweb indentation wrong in Internet Explorer
Message-ID: <egjllu$6k8$1@sea.gmane.org>
URL: https://gitlist.dev/e/egjllu%246k8%241%40sea.gmane.org
In-Reply-To: <egjang$nmh$1@sea.gmane.org>

```
Jakub Narebski wrote:

> Which version of gitweb? We have removed s/ /&nbsp;/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, 2006-10-11 21:13

Subject: [PATCH] Removes the <?xml?> declaration from gitweb.pl
Message-ID: <egjmri$atp$1@sea.gmane.org>
URL: https://gitlist.dev/e/egjmri%24atp%241%40sea.gmane.org
In-Reply-To: <egjllu$6k8$1@sea.gmane.org>

```
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, 2006-10-11 21:27

Subject: Re: [PATCH] Removes the <?xml?> declaration from gitweb.pl
Message-ID: <egjnk5$bpn$2@sea.gmane.org>
URL: https://gitlist.dev/e/egjnk5%24bpn%242%40sea.gmane.org
In-Reply-To: <egjmri$atp$1@sea.gmane.org>

```
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, 2006-10-12 00:26

Subject: Re: [PATCH] Removes the <?xml?> declaration from gitweb.pl
Message-ID: <egk24r$hgb$1@sea.gmane.org>
URL: https://gitlist.dev/e/egk24r%24hgb%241%40sea.gmane.org
In-Reply-To: <egjnk5$bpn$2@sea.gmane.org>

```
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, 2006-10-12 01:08

Subject: Re: [PATCH] Removes the <?xml?> declaration from gitweb.pl
Message-ID: <egk4im$njm$1@sea.gmane.org>
URL: https://gitlist.dev/e/egk4im%24njm%241%40sea.gmane.org
In-Reply-To: <egjnk5$bpn$2@sea.gmane.org>

```
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, 2006-10-12 05:45

Subject: Re: [PATCH] Removes the <?xml?> declaration from gitweb.pl
Message-ID: <200610120745.00909.robin.rosenberg.lists@dewire.com>
URL: https://gitlist.dev/e/200610120745.00909.robin.rosenberg.lists%40dewire.com
In-Reply-To: <egjnk5$bpn$2@sea.gmane.org>

```
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.

-- robin

```

## Jakub Narebski, 2006-10-12 21:21

Subject: Re: [PATCH] Removes the <?xml?> declaration from gitweb.pl
Message-ID: <200610122321.18630.jnareb@gmail.com>
URL: https://gitlist.dev/e/200610122321.18630.jnareb%40gmail.com
In-Reply-To: <200610120745.00909.robin.rosenberg.lists@dewire.com>

```
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?
-- 
Jakub Narebski
Poland

```

## Pazu, 2006-10-13 13:01

Subject: Re: [PATCH] Removes the <?xml?> declaration from gitweb.pl
Message-ID: <ego2nk$3nm$1@sea.gmane.org>
URL: https://gitlist.dev/e/ego2nk%243nm%241%40sea.gmane.org
In-Reply-To: <200610122321.18630.jnareb@gmail.com>

```
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, 2006-10-13 13:07

Subject: Re: [PATCH] Removes the <?xml?> declaration from gitweb.pl
Message-ID: <ego331$568$2@sea.gmane.org>
URL: https://gitlist.dev/e/ego331%24568%242%40sea.gmane.org
In-Reply-To: <ego2nk$3nm$1@sea.gmane.org>

```
Pazu wrote:

> 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

```

## Robin Rosenberg, 2006-10-13 14:05

Subject: Re: [PATCH] Removes the <?xml?> declaration from gitweb.pl
Message-ID: <200610131605.56913.robin.rosenberg.lists@dewire.com>
URL: https://gitlist.dev/e/200610131605.56913.robin.rosenberg.lists%40dewire.com
In-Reply-To: <200610122321.18630.jnareb@gmail.com>

```
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?

-- robin

```

## Pazu, 2006-10-13 14:09

Subject: Re: [PATCH] Removes the <?xml?> declaration from gitweb.pl
Message-ID: <ego6nn$l78$1@sea.gmane.org>
URL: https://gitlist.dev/e/ego6nn%24l78%241%40sea.gmane.org
In-Reply-To: <ego331$568$2@sea.gmane.org>

```
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

```

## Jakub Narebski, 2006-10-13 15:09

Subject: Re: [PATCH] Removes the <?xml?> declaration from gitweb.pl
Message-ID: <200610131709.08515.jnareb@gmail.com>
URL: https://gitlist.dev/e/200610131709.08515.jnareb%40gmail.com
In-Reply-To: <200610131605.56913.robin.rosenberg.lists@dewire.com>

```
Robin Rosenberg wrote:
> 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

```
