Mercurial > public > mercurial-scm > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
10673:9848b39a1472 | 10674:6d87c20cd7a8 |
---|---|
4 # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> | 4 # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> |
5 # | 5 # |
6 # This software may be used and distributed according to the terms of the | 6 # This software may be used and distributed according to the terms of the |
7 # GNU General Public License version 2 or any later version. | 7 # GNU General Public License version 2 or any later version. |
8 | 8 |
9 import os, re, time | 9 import os, re, time, urlparse |
10 from mercurial.i18n import _ | 10 from mercurial.i18n import _ |
11 from mercurial import ui, hg, util, templater | 11 from mercurial import ui, hg, util, templater |
12 from mercurial import error, encoding | 12 from mercurial import error, encoding |
13 from common import ErrorResponse, get_mtime, staticfile, paritygen, \ | 13 from common import ErrorResponse, get_mtime, staticfile, paritygen, \ |
14 get_contact, HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR | 14 get_contact, HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR |
337 "staticurl": staticurl, | 337 "staticurl": staticurl, |
338 "sessionvars": sessionvars}) | 338 "sessionvars": sessionvars}) |
339 return tmpl | 339 return tmpl |
340 | 340 |
341 def updatereqenv(self, env): | 341 def updatereqenv(self, env): |
342 def splitnetloc(netloc): | |
343 if ':' in netloc: | |
344 return netloc.split(':', 1) | |
345 else: | |
346 return (netloc, None) | |
347 | |
342 if self._baseurl is not None: | 348 if self._baseurl is not None: |
343 env['SCRIPT_NAME'] = self._baseurl | 349 urlcomp = urlparse.urlparse(self._baseurl) |
350 host, port = splitnetloc(urlcomp[1]) | |
351 path = urlcomp[2] | |
352 env['SERVER_NAME'] = host | |
353 if port: | |
354 env['SERVER_PORT'] = port | |
355 env['SCRIPT_NAME'] = path |