Mercurial > public > mercurial-scm > hg
diff mercurial/hgweb/hgwebdir_mod.py @ 10674:6d87c20cd7a8 stable
hgweb: fix broken URLs of RSS/Atom feeds (issue1772)
This fixes doubled URL, e.g. http://example.orghttp://example.org/...,
which appears on RSS/Atom feeds served by hgwebdir.
It splits baseurl to update SERVER_NAME, SERVER_PORT and SCRIPT_NAME,
according to RFC 3875.
Updated the test output since SCRIPT_NAME becomes not to contain
http://host:port part.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 11 Mar 2010 00:28:27 +0900 |
parents | 9848b39a1472 |
children | 3c05ecffe20d |
line wrap: on
line diff
--- a/mercurial/hgweb/hgwebdir_mod.py Thu Mar 11 00:25:46 2010 +0900 +++ b/mercurial/hgweb/hgwebdir_mod.py Thu Mar 11 00:28:27 2010 +0900 @@ -6,7 +6,7 @@ # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. -import os, re, time +import os, re, time, urlparse from mercurial.i18n import _ from mercurial import ui, hg, util, templater from mercurial import error, encoding @@ -339,5 +339,17 @@ return tmpl def updatereqenv(self, env): + def splitnetloc(netloc): + if ':' in netloc: + return netloc.split(':', 1) + else: + return (netloc, None) + if self._baseurl is not None: - env['SCRIPT_NAME'] = self._baseurl + urlcomp = urlparse.urlparse(self._baseurl) + host, port = splitnetloc(urlcomp[1]) + path = urlcomp[2] + env['SERVER_NAME'] = host + if port: + env['SERVER_PORT'] = port + env['SCRIPT_NAME'] = path