XML 安装 BugZilla perl 依赖项后尝试配置 gitweb 时出现解析错误

XML parsing error when trying to configure gitweb after installing BugZilla perl dependencies

我在个人服务器上安装并配置了 git、gitolite 和 gitweb,一开始它运行良好,我的存储库上有我的 web 视图。但是当我尝试安装 BugZilla(使用 all perl dependencies)时,我在 gitweb URL:

的 racine 上收到一条错误消息
XML Parsing Error: XML or text declaration not at start of entity Location: http://xxx.xxx.xx.xx/gitweb/ Line Number 22, Column 1:

生成的网页(firebug):

<?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 1.7.10.4, (C) 2005-2006, Kay Sievers <kay.sievers@vrfy.org>, Christian Gierke -->
<!-- git core binaries version 1.7.10.4 -->
<head>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8"/>
<meta name="generator" content="gitweb/1.7.10.4 git/1.7.10.4"/>
<meta name="robots" content="index, nofollow"/>
<title>xxx.xxx.xx.xx Git</title>
<link rel="stylesheet" type="text/css" href="static/gitweb.css"/>
<link rel="alternate" title="xxx.xxx.xx.xx Git projects list" href="/gitweb/?a=project_index" type="text/plain; charset=utf-8" />
<link rel="alternate" title="xxx.xxx.xx.xx Git projects feeds" href="/gitweb/?a=opml" type="text/x-opml" />
<link rel="shortcut icon" href="static/git-favicon.png" type="image/png" />
</head>
<body>
<div class="page_header">
<a href="http://git-scm.com/" title="git homepage"><img alt="git" class="logo" height="27" src="static/git-logo.png" width="72" /></a><a href="/gitweb/">projects</a> / </div>
<div class="projsearch">
Content-type: text/html

<?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 1.7.10.4, (C) 2005-2006, Kay Sievers <kay.sievers@vrfy.org>, Christian Gierke -->
<!-- git core binaries version 1.7.10.4 -->
<head>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8"/>
<meta name="generator" content="gitweb/1.7.10.4 git/1.7.10.4"/>
<meta name="robots" content="index, nofollow"/>
<title>xxx.xxx.xx.xx Git</title>
<link rel="stylesheet" type="text/css" href="static/gitweb.css"/>
<link rel="shortcut icon" href="static/git-favicon.png" type="image/png" />
</head>
<body>
<div class="page_header">
<a href="http://git-scm.com/" title="git homepage"><img alt="git" class="logo" height="27" src="static/git-logo.png" width="72" /></a><a href="/gitweb/">projects</a> / </div>
<div class="page_body">
<br /><br />
500 - Internal Server Error
<br />
<hr />
Can't locate object method &quot;startform&quot; via package &quot;CGI&quot; at /usr/share/gitweb/index.cgi line 5267.

</div>
<div class="page_footer">
<a class="rss_logo" href="/gitweb/?a=opml">OPML</a> <a class="rss_logo" href="/gitweb/?a=project_index">TXT</a>
</div>
<script type="text/javascript" src="static/gitweb.js"></script>
<script type="text/javascript">
window.onload = function () {
    var tz_cookie = { name: 'gitweb_tz', expires: 14, path: '/' };
    onloadTZSetup('local', tz_cookie, 'datetime');
};
</script>
</body>
</html>

我认为这个错误是因为我在尝试安装 BugZilla 时安装了 perl 模块。

如何卸载所有 perl 模块并重新安装默认模块?

我使用 Apache 作为 Web 服务器。

有人知道如何解决这个问题吗?

更新1:

我的 perl 版本是:v5.14.2

CGI 版本:4.21

在 Windows 上,使用 ActivePerl 或 Strawberry 5.22 我遇到了同样的错误。安装 CGI 模块并将 gitweb.cgi 中的两个 "startform" 实例替换为 "start_form" 解决了问题。

但是出于某种原因我仍然无法让 gitweb 列出我的项目。 Git 版本为 1.9.5。

升级到 16.04 后,Ubuntu 上的 gitweb 和 apache 出现相同的错误消息。正如 Slion 所说,将 "startform" 的两个实例更改为 gitweb.cgi 中的 "start_form" 有效,我可以像以前一样使用 gitweb。

在我的例子中,下面的命令在 Arch 上非常有用 Linux。

$ sudo pacman -Rs perl-cgi #uninstalls
$ sudo pacman -S perl #updates to the latest version
$ sudo pacman -S perl-cgi #installs

(您可能认为这与 sudo pacman -S perl-cgi 相同,但在我的例子中,perl-cgi 已经是最新的了。虽然也许只需升级 perl 就可以,但上面的命令是反正我做了什么。)

我找到这个解决方案是因为在我的主台式计算机(perl 5.30.3)上成功进行简单测试后,我在我的服务器(perl 5.30.2)上遇到了错误。

此错误 () 可能不会出现在 Git 2.36(2022 年第二季度,七年后), 中删除不需要的 <meta http-equiv=content-type...> =12=]输出。

参见 commit a262585, commit 943fd02 (08 Mar 2022) by Jason Yundt (Jayman2000)
(由 Junio C Hamano -- gitster -- in commit bc3838b 合并,2022 年 3 月 21 日)

gitweb: remove invalid http-equiv="content-type"

Signed-off-by: Jason Yundt

Before this change, gitweb would generate pages which included:

<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8"/>

When a meta's http-equiv equals "content-type", the http-equiv is said to be in the "Encoding declaration state".
According to the HTML Standard:

The Encoding declaration state may be used in HTML documents, but elements with an http-equiv attribute in that state must not be used in XML documents.

(Source)

This change removes that meta element since gitweb always generates XML documents.