hgweb.cgi
author Pulkit Goyal <7895pulkit@gmail.com>
Wed, 07 Oct 2020 14:26:47 +0530
changeset 45787 225e513c444e
parent 45398 d58a205d0672
child 45830 c102b704edb5
permissions -rwxr-xr-x
tags: add safety check for len(record) while reading hgtagsfnodescache I am trying to fix a breakage where somehow we end up getting a node of 12 length from `getfnode()`. Understanding the hgtagsfnodescache code, it seems highly unlikely that it can happen unless one of `mctx.readfast().get()` or `ctx.filenode()` is returning a node of 12 length. For safety, I think it's better to add a check to make sure that record which we are parsing is of same length we are expecting otherwise we consider that as invalid record. Differential Revision: https://phab.mercurial-scm.org/D9169

#!/usr/bin/env python
#
# An example hgweb CGI script, edit as necessary
# See also https://mercurial-scm.org/wiki/PublishingRepositories

# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = b"/path/to/repo/or/config"

# Uncomment and adjust if Mercurial is not installed system-wide
# (consult "installed modules" path from 'hg debuginstall'):
# import sys; sys.path.insert(0, "/path/to/python/lib")

# Uncomment to send python tracebacks to the browser if an error occurs:
# import cgitb; cgitb.enable()

from mercurial import demandimport

demandimport.enable()
from mercurial.hgweb import hgweb, wsgicgi

application = hgweb(config)
wsgicgi.launch(application)