Patchwork D3432: hgweb: guard against empty Content-Length header

login
register
mail settings
Submitter phabricator
Date April 27, 2018, 9:52 p.m.
Message ID <differential-rev-PHID-DREV-jdi3rlt2t2w57oewrrz3-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/31244/
State Superseded
Headers show

Comments

phabricator - April 27, 2018, 9:52 p.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Discussion in issue 5860 seems to indicate this can occur.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3432

AFFECTED FILES
  mercurial/hgweb/request.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel
phabricator - April 28, 2018, 3:26 a.m.
mharbison72 added a comment.


  LGTM.  Here's the PEP reference allowing that:
  
  https://www.python.org/dev/peps/pep-3333/#environ-variables
  
  I'm not sure why this isn't working as expected:
  
  https://bitbucket.org/sdorra/scm-manager/commits/60d9b631c557cd8523c87d3eaa38fff13592ce9b#Lscm-webapp/src/main/java/sonia/scm/web/cgi/DefaultCGIExecutor.javaT368

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3432

To: indygreg, #hg-reviewers
Cc: mharbison72, mercurial-devel

Patch

diff --git a/mercurial/hgweb/request.py b/mercurial/hgweb/request.py
--- a/mercurial/hgweb/request.py
+++ b/mercurial/hgweb/request.py
@@ -313,7 +313,8 @@ 
     if bodyfh is None:
         bodyfh = env['wsgi.input']
         if 'Content-Length' in headers:
-            bodyfh = util.cappedreader(bodyfh, int(headers['Content-Length']))
+            bodyfh = util.cappedreader(bodyfh,
+                                       int(headers['Content-Length'] or '0'))
 
     return parsedrequest(method=env['REQUEST_METHOD'],
                          url=fullurl, baseurl=baseurl,