##// END OF EJS Templates
hgweb: rewrite most obviously-native-strings to be native strings...
Augie Fackler -
r34705:c5138087 default
parent child Browse files
Show More
@@ -14,6 +14,7 from ..i18n import _
14 14
15 15 from .. import (
16 16 error,
17 pycompat,
17 18 util,
18 19 )
19 20
@@ -61,25 +62,26 class httpservice(object):
61 62 else:
62 63 prefix = ''
63 64
64 port = ':%d' % self.httpd.port
65 if port == ':80':
66 port = ''
65 port = r':%d' % self.httpd.port
66 if port == r':80':
67 port = r''
67 68
68 69 bindaddr = self.httpd.addr
69 if bindaddr == '0.0.0.0':
70 bindaddr = '*'
71 elif ':' in bindaddr: # IPv6
72 bindaddr = '[%s]' % bindaddr
70 if bindaddr == r'0.0.0.0':
71 bindaddr = r'*'
72 elif r':' in bindaddr: # IPv6
73 bindaddr = r'[%s]' % bindaddr
73 74
74 75 fqaddr = self.httpd.fqaddr
75 if ':' in fqaddr:
76 fqaddr = '[%s]' % fqaddr
76 if r':' in fqaddr:
77 fqaddr = r'[%s]' % fqaddr
77 78 if self.opts['port']:
78 79 write = self.ui.status
79 80 else:
80 81 write = self.ui.write
81 82 write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
82 (fqaddr, port, prefix, bindaddr, self.httpd.port))
83 (pycompat.sysbytes(fqaddr), pycompat.sysbytes(port),
84 prefix, pycompat.sysbytes(bindaddr), self.httpd.port))
83 85 self.ui.flush() # avoid buffering of status message
84 86
85 87 def run(self):
@@ -165,9 +165,9 class requestcontext(object):
165 165 proto = 'http'
166 166 default_port = '80'
167 167
168 port = req.env['SERVER_PORT']
169 port = port != default_port and (':' + port) or ''
170 urlbase = '%s://%s%s' % (proto, req.env['SERVER_NAME'], port)
168 port = req.env[r'SERVER_PORT']
169 port = port != default_port and (r':' + port) or r''
170 urlbase = r'%s://%s%s' % (proto, req.env[r'SERVER_NAME'], port)
171 171 logourl = self.config('web', 'logourl')
172 172 logoimg = self.config('web', 'logoimg')
173 173 staticurl = self.config('web', 'staticurl') or req.url + 'static/'
@@ -341,27 +341,27 class hgweb(object):
341 341 # work with CGI variables to create coherent structure
342 342 # use SCRIPT_NAME, PATH_INFO and QUERY_STRING as well as our REPO_NAME
343 343
344 req.url = req.env['SCRIPT_NAME']
344 req.url = req.env[r'SCRIPT_NAME']
345 345 if not req.url.endswith('/'):
346 346 req.url += '/'
347 347 if req.env.get('REPO_NAME'):
348 req.url += req.env['REPO_NAME'] + '/'
348 req.url += req.env[r'REPO_NAME'] + r'/'
349 349
350 if 'PATH_INFO' in req.env:
351 parts = req.env['PATH_INFO'].strip('/').split('/')
352 repo_parts = req.env.get('REPO_NAME', '').split('/')
350 if r'PATH_INFO' in req.env:
351 parts = req.env[r'PATH_INFO'].strip('/').split('/')
352 repo_parts = req.env.get(r'REPO_NAME', r'').split(r'/')
353 353 if parts[:len(repo_parts)] == repo_parts:
354 354 parts = parts[len(repo_parts):]
355 355 query = '/'.join(parts)
356 356 else:
357 query = req.env['QUERY_STRING'].partition('&')[0]
358 query = query.partition(';')[0]
357 query = req.env[r'QUERY_STRING'].partition(r'&')[0]
358 query = query.partition(r';')[0]
359 359
360 360 # process this if it's a protocol request
361 361 # protocol bits don't need to create any URLs
362 362 # and the clients always use the old URL structure
363 363
364 cmd = req.form.get('cmd', [''])[0]
364 cmd = pycompat.sysbytes(req.form.get(r'cmd', [r''])[0])
365 365 if protocol.iscmd(cmd):
366 366 try:
367 367 if query:
@@ -386,8 +386,7 class hgweb(object):
386 386 # translate user-visible url structure to internal structure
387 387
388 388 args = query.split('/', 2)
389 if 'cmd' not in req.form and args and args[0]:
390
389 if r'cmd' not in req.form and args and args[0]:
391 390 cmd = args.pop(0)
392 391 style = cmd.rfind('-')
393 392 if style != -1:
@@ -396,7 +395,7 class hgweb(object):
396 395
397 396 # avoid accepting e.g. style parameter as command
398 397 if util.safehasattr(webcommands, cmd):
399 req.form['cmd'] = [cmd]
398 req.form[r'cmd'] = [cmd]
400 399
401 400 if cmd == 'static':
402 401 req.form['file'] = ['/'.join(args)]
@@ -431,8 +430,8 class hgweb(object):
431 430 self.check_perm(rctx, req, None)
432 431
433 432 if cmd == '':
434 req.form['cmd'] = [tmpl.cache['default']]
435 cmd = req.form['cmd'][0]
433 req.form[r'cmd'] = [tmpl.cache['default']]
434 cmd = req.form[r'cmd'][0]
436 435
437 436 # Don't enable caching if using a CSP nonce because then it wouldn't
438 437 # be a nonce.
@@ -441,7 +440,7 class hgweb(object):
441 440 if cmd not in webcommands.__all__:
442 441 msg = 'no such method: %s' % cmd
443 442 raise ErrorResponse(HTTP_BAD_REQUEST, msg)
444 elif cmd == 'file' and 'raw' in req.form.get('style', []):
443 elif cmd == 'file' and r'raw' in req.form.get(r'style', []):
445 444 rctx.ctype = ctype
446 445 content = webcommands.rawfile(rctx, req, tmpl)
447 446 else:
General Comments 0
You need to be logged in to leave comments. Login now