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