threads / discuss / 22612

XML Parsing Error: junk after document element

Subject: XML Parsing Error: junk after document element

## tl;dr

5 messages between Feb 11, 2010 and Feb 17, 2010.

replies: 4people: 2as markdown or json

Siju George· Feb 11, 2010, 07:47 UTC · lore
Hi,
I get this error when I take gitweb in a browser.
XML Parsing Error: junk after document element
Location: http://172.16.3.27/cgi-bin/gitweb.cgi
Line Number 28, Column 8:</html><!DOCTYPE HTML PUBLIC "-//IETF//DTD
HTML 2.0//EN">
-------^
How can I solve it?
Thanks
--Siju
Jakub Narebski· Feb 11, 2010, 11:01 UTC · re: Siju George · lore

Re: XML Parsing Error: junk after document element

Siju George <sgeorge.ml@gmail.com> writes:
Show 11 quoted lines
> Hi,
> 
> I get this error when I take gitweb in a browser.
> 
> XML Parsing Error: junk after document element
> Location: http://172.16.3.27/cgi-bin/gitweb.cgi
> Line Number 28, Column 8:</html><!DOCTYPE HTML PUBLIC "-//IETF//DTD
> HTML 2.0//EN">
> -------^
> 
> How can I solve it?

Which version of gitweb?[1] Which version of git?[2] What web server? Which version of CGI.pm is used by web server?[3]

The included fragment after closing '</html>' tag doesn't look like something coming from gitweb, as gitweb uses XHTML 1.0 DTD since it's first version.

Try to view source, or use different web browser that doesn't do strict XML validation to find the source of this error.

If everything else fals, you can always edit gitweb.cgi to comment out content-type negotiation, to always serve as text/html mimetype - which should torn off XML validation, as below:

	my $content_type;
	# require explicit support from the UA if we are to send the page as
	# 'application/xhtml+xml', otherwise send it as plain old 'text/html'.
	# we have to do this because MSIE sometimes globs '*/*', pretending to
	# support xhtml+xml but choking when it gets what it asked for.
	# Disable content-type negotiation when caching (use mimetype good for all).
	#if (defined $cgi->http('HTTP_ACCEPT') &&
	#    $cgi->http('HTTP_ACCEPT') =~ m/(,|;|\s|^)application\/xhtml\+xml(,|;|\s|$)/ &&
	#    $cgi->Accept('application/xhtml+xml') != 0) {
	#	$content_type = 'application/xhtml+xml';
	#} else {
		$content_type = 'text/html';
	#}

The commands below are _examples_ only: [1] grep -F 'our $version' /var/www/cgi-bin/gitweb.cgi [2] git --version [3] perl -MCGI -le 'print $CGI::VERSION'

-- 
Jakub Narebski
Poland
ShadeHawk on #git
Siju George· Feb 12, 2010, 04:23 UTC · re: Jakub Narebski · lore

Re: XML Parsing Error: junk after document element

Thanks a lot Jakub for the response :-)
On Thu, Feb 11, 2010 at 4:31 PM, Jakub Narebski <jnareb@gmail.com> wrote:
>
> Which version of gitweb?[1]
>
 gitweb-1.6.0.6  - all packages are from pkgsrc on DragonFly BSD
v2.5.1.672.gf81ef-DEVELOPMENT #17: Tue Feb
> Which version of git?[2]
>
scmgit-1.6.6.1
>What web server?
>
 apache-2.2.14nb1
> Which version of CGI.pm is used by web server?[3]
>

$CGI::revision = '$Id: CGI.pm,v 1.263 2009/02/11 16:56:37 lstein Exp $'; $CGI::VERSION='3.43';

> Try to view source, or use different web browser that doesn't do
> strict XML validation to find the source of this error.
>

I was using firefox 3.6-2. Trying with Konqueror Version 4.3.4 (KDE 4.3.4) Using KDE 4.3.4 (KDE 4.3.4) I dont get the error but it does not list my projectts. I get this message on the page.

=================================================
projects /
 404 - No projects found

OPMLTXT OK The requested URL /cgi-bin/gitweb.cgi was not found on this server.

======================================================
this page is shown when I take the URL
http://172.16.3.27/cgi-bin/gitweb.cgi

but I have the projectroot configure in gitweb.conf and there is a git project in that location.

# cat /usr/pkg/etc/gitweb.conf | grep projectroot our $projectroot = "/Backup1/Data/git-repositories"; # ls -l /Backup1/Data/git-repositories total 0 drwxr-xr-x 1 root wheel 0 Feb 11 10:40 systems-configuration # ls -l /Backup1/Data/git-repositories/systems-configuration/.git/ total 0 -rwxr-x--- 1 root wheel 393 Feb 11 11:03 COMMIT_EDITMSG -rwxr-x--- 1 root wheel 23 Feb 11 10:40 HEAD -rwxr-x--- 1 root wheel 92 Feb 11 10:40 config -rwxr-x--- 1 root wheel 73 Feb 11 10:40 description drwxr-x--- 1 root wheel 0 Feb 11 10:40 hooks -rwxr-x--- 1 root wheel 120 Feb 11 11:29 index drwxr-x--- 1 root wheel 0 Feb 11 10:40 info drwxr-x--- 1 root wheel 0 Feb 11 10:58 logs drwxr-x--- 1 root wheel 0 Feb 11 11:03 objects drwxr-x--- 1 root wheel 0 Feb 11 10:40 refs #

Show 19 quoted lines
> If everything else fals, you can always edit gitweb.cgi to comment out
> content-type negotiation, to always serve as text/html mimetype -
> which should torn off XML validation, as below:
>
>        my $content_type;
>        # require explicit support from the UA if we are to send the page as
>        # 'application/xhtml+xml', otherwise send it as plain old 'text/html'.
>        # we have to do this because MSIE sometimes globs '*/*', pretending to
>        # support xhtml+xml but choking when it gets what it asked for.
>        # Disable content-type negotiation when caching (use mimetype good for all).
>        #if (defined $cgi->http('HTTP_ACCEPT') &&
>        #    $cgi->http('HTTP_ACCEPT') =~ m/(,|;|\s|^)application\/xhtml\+xml(,|;|\s|$)/ &&
>        #    $cgi->Accept('application/xhtml+xml') != 0) {
>        #       $content_type = 'application/xhtml+xml';
>        #} else {
>                $content_type = 'text/html';
>        #}
>
>

yes I tried it and the first error disappears from firefor and now I get the same error from konqueror in firefox too

What could be the trouble?
Thanks
--Siju
Jakub Narebski· Feb 12, 2010, 10:48 UTC · re: Siju George · lore

Re: XML Parsing Error: junk after document element

On Fri, Feb 12, 2010, Siju George wrote:
Show 10 quoted lines
> On Thu, Feb 11, 2010 at 4:31 PM, Jakub Narebski <jnareb@gmail.com> wrote:
> >
> > Which version of gitweb?[1]
> 
> gitweb-1.6.0.6  - all packages are from pkgsrc on DragonFly BSD
> v2.5.1.672.gf81ef-DEVELOPMENT #17: Tue Feb
> 
> > Which version of git?[2]
> 
> scmgit-1.6.6.1
I don't think that difference in version numbers would be the problem.
Is this a version of git that gitweb (or to be more accurate web server)
sees?  Take a look at HTML source of page returned by gitweb, and at
the top there would be 'git core binaries version' in comment, and
'git/<version>' in the meta generator tag (this can be seen also in
"View Page Info" view, not only in "View Page Source").
 
Show 9 quoted lines
> > What web server?
>  
>  apache-2.2.14nb1
>
> > Which version of CGI.pm is used by web server?[3]
> >
> 
> $CGI::revision = '$Id: CGI.pm,v 1.263 2009/02/11 16:56:37 lstein Exp $';
> $CGI::VERSION='3.43';
This should not be a problem then.
Show 19 quoted lines
> > Try to view source, or use different web browser that doesn't do
> > strict XML validation to find the source of this error.
> >
> 
> I was using firefox 3.6-2.
> Trying with Konqueror Version 4.3.4 (KDE 4.3.4) Using KDE 4.3.4 (KDE
> 4.3.4) I dont get the error but it does not list my projectts. I get
> this message on the page.
> 
> =================================================
> 
> projects /
> 
> 
>  404 - No projects found
> 
> OPMLTXT
> OK
> The requested URL /cgi-bin/gitweb.cgi was not found on this server.

You have two problems here. First is that gitweb doesn't find your projects because of problem with filesystem permissions.

Second is what it looks misconfigured web server. The second part, starting after [OPML][TXT] is not from gitweb, but from a web server. It looks like you have either two web servers, or two parts of web server configuration, or some worker of web server that didn't get updated configuration, and it doesn't have permissions to access gitweb.cgi or doesn't have configuration to know what to do with the above URL.

What might help is, if you can, to restart your web server, something like

  # apachectl restart           # as root
(I don't know what the proper command would be on DragonFlyBSD).
Show 26 quoted lines
> ======================================================
> 
> this page is shown when I take the URL
> 
> http://172.16.3.27/cgi-bin/gitweb.cgi
> 
> but I have the projectroot configure in gitweb.conf and there is a git
> project in that location.
> 
> # cat /usr/pkg/etc/gitweb.conf | grep projectroot
> our $projectroot = "/Backup1/Data/git-repositories";
> # ls -l /Backup1/Data/git-repositories
> total 0
> drwxr-xr-x  1 root  wheel  0 Feb 11 10:40 systems-configuration
> # ls -l /Backup1/Data/git-repositories/systems-configuration/.git/
> total 0
> -rwxr-x---  1 root  wheel  393 Feb 11 11:03 COMMIT_EDITMSG
> -rwxr-x---  1 root  wheel   23 Feb 11 10:40 HEAD
> -rwxr-x---  1 root  wheel   92 Feb 11 10:40 config
> -rwxr-x---  1 root  wheel   73 Feb 11 10:40 description
> drwxr-x---  1 root  wheel    0 Feb 11 10:40 hooks
> -rwxr-x---  1 root  wheel  120 Feb 11 11:29 index
> drwxr-x---  1 root  wheel    0 Feb 11 10:40 info
> drwxr-x---  1 root  wheel    0 Feb 11 10:58 logs
> drwxr-x---  1 root  wheel    0 Feb 11 11:03 objects
> drwxr-x---  1 root  wheel    0 Feb 11 10:40 refs

Apache web server usually runs as apache:apache (user apache, group apache); it most certainly *not* run as root, or is in wheel (root-like) group. So as you can see web server, and gitweb which runs with the same uid and guid, doesn't have permissions to read (access) your repositories.

You need to fix permissions, perhaps (as it seems to be your private machine and private gitweb) by setting group to some common group between you and web server and giving sticky group bit, or making git repository world-readable: take a look at "shared repository" thing: see description of core.sharedRepository config variable (so that git wouldn't take world-readable permissions back).

BTW. what are you doing working as root?
> What could be the trouble?

Filesystem permissions on git repository, and some strange error in web server configuration. Unfortunately I haven't got a clue what to do about the latter.

-- 
Jakub Narebski
Poland
Siju George· Feb 17, 2010, 09:46 UTC · re: Jakub Narebski · lore

Re: XML Parsing Error: junk after document element

On Fri, Feb 12, 2010 at 4:18 PM, Jakub Narebski <jnareb@gmail.com> wrote:
Show 11 quoted lines
> You have two problems here.  First is that gitweb doesn't find your
> projects because of problem with filesystem permissions.
>
> Second is what it looks misconfigured web server.  The second part,
> starting after [OPML][TXT] is not from gitweb, but from a web server.
> It looks like you have either two web servers, or two parts of web
> server configuration, or some worker of web server that didn't get
> updated configuration, and it doesn't have permissions to access
> gitweb.cgi or doesn't have configuration to know what to do with
> the above URL.
>

Hi once i changed the permissions of the git repositories every thing is looking fine :-)

Thanks
--Siju

← back to recent threads