Skip to content

Commit

Permalink
Fixed invalid escape sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
buglloc committed Nov 22, 2018
1 parent cbc7f91 commit 340f715
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions gixy/core/builtin_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@

BUILTIN_VARIABLES = {
# http://nginx.org/en/docs/http/ngx_http_core_module.html#var_uri
'uri': '/[^\x20\t]*',
'uri': r'/[^\x20\t]*',
# http://nginx.org/en/docs/http/ngx_http_core_module.html#var_document_uri
'document_uri': '/[^\x20\t]*',
'document_uri': r'/[^\x20\t]*',
# http://nginx.org/en/docs/http/ngx_http_core_module.html#var_arg_
'arg_': '[^\s&]+',
'arg_': r'[^\s&]+',
# http://nginx.org/en/docs/http/ngx_http_core_module.html#var_args
'args': '[^\s]+',
'args': r'[^\s]+',
# http://nginx.org/en/docs/http/ngx_http_core_module.html#var_query_string
'query_string': '[^\s]+',
'query_string': r'[^\s]+',
# http://nginx.org/en/docs/http/ngx_http_core_module.html#var_request_uri
'request_uri': '/[^\s]*',
'request_uri': r'/[^\s]*',
# http://nginx.org/en/docs/http/ngx_http_core_module.html#var_http_
'http_': '[\x21-\x7e]',
'http_': r'[\x21-\x7e]',

# http://nginx.org/en/docs/http/ngx_http_upstream_module.html#var_upstream_http_
'upstream_http_': '',
Expand Down
2 changes: 1 addition & 1 deletion gixy/directives/directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def variables(self):
class RewriteDirective(Directive):
nginx_name = 'rewrite'
provide_variables = True
boundary = Regexp('[^\s\r\n]')
boundary = Regexp(r'[^\s\r\n]')

def __init__(self, name, args):
super(RewriteDirective, self).__init__(name, args)
Expand Down
2 changes: 1 addition & 1 deletion gixy/plugins/http_splitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class http_splitting(Plugin):
"""
r"""
Insecure examples:
rewrite ^ http://$host$uri;
return 301 http://$host$uri;
Expand Down
4 changes: 2 additions & 2 deletions gixy/plugins/origins.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class origins(Plugin):
"""
r"""
Insecure example:
if ($http_referer !~ "^https?://([^/]+metrika.*yandex\.ru/"){
add_header X-Frame-Options SAMEORIGIN;
Expand All @@ -29,7 +29,7 @@ def __init__(self, config):
if self.config.get('domains') and self.config.get('domains')[0] and self.config.get('domains')[0] != '*':
domains = '|'.join(re.escape(d) for d in self.config.get('domains'))
else:
domains = '[^/.]*\.[^/]{2,7}'
domains = r'[^/.]*\.[^/]{2,7}'

scheme = 'https{http}'.format(http=('?' if not self.config.get('https_only') else ''))
regex = r'^{scheme}://(?:[^/.]*\.){{0,10}}(?P<domain>{domains})(?::\d*)?(?:/|\?|$)'.format(
Expand Down

0 comments on commit 340f715

Please sign in to comment.