Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/hgweb_mod.py @ 50893:b2b8c25f9462
hgwebmod: use sysstr to check for attribute presence
We do not need bytes here.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 30 Aug 2023 13:28:09 +0200 |
parents | 3b642b384b14 |
children | d718eddf01d9 |
comparison
equal
deleted
inserted
replaced
50892:a834ec41f17c | 50893:b2b8c25f9462 |
---|---|
401 if style != -1: | 401 if style != -1: |
402 req.qsparams[b'style'] = cmd[:style] | 402 req.qsparams[b'style'] = cmd[:style] |
403 cmd = cmd[style + 1 :] | 403 cmd = cmd[style + 1 :] |
404 | 404 |
405 # avoid accepting e.g. style parameter as command | 405 # avoid accepting e.g. style parameter as command |
406 if util.safehasattr(webcommands, cmd): | 406 if util.safehasattr(webcommands, pycompat.sysstr(cmd)): |
407 req.qsparams[b'cmd'] = cmd | 407 req.qsparams[b'cmd'] = cmd |
408 | 408 |
409 if cmd == b'static': | 409 if cmd == b'static': |
410 req.qsparams[b'file'] = b'/'.join(args) | 410 req.qsparams[b'file'] = b'/'.join(args) |
411 else: | 411 else: |
472 else: | 472 else: |
473 # Set some globals appropriate for web handlers. Commands can | 473 # Set some globals appropriate for web handlers. Commands can |
474 # override easily enough. | 474 # override easily enough. |
475 res.status = b'200 Script output follows' | 475 res.status = b'200 Script output follows' |
476 res.headers[b'Content-Type'] = ctype | 476 res.headers[b'Content-Type'] = ctype |
477 return getattr(webcommands, cmd)(rctx) | 477 return getattr(webcommands, pycompat.sysstr(cmd))(rctx) |
478 | 478 |
479 except (error.LookupError, error.RepoLookupError) as err: | 479 except (error.LookupError, error.RepoLookupError) as err: |
480 msg = pycompat.bytestr(err) | 480 msg = pycompat.bytestr(err) |
481 if util.safehasattr(err, 'name') and not isinstance( | 481 if util.safehasattr(err, 'name') and not isinstance( |
482 err, error.ManifestLookupError | 482 err, error.ManifestLookupError |