Skip to content

Commit

Permalink
Regex string escape properly
Browse files Browse the repository at this point in the history
  • Loading branch information
humitos committed Nov 28, 2018
1 parent f0edd22 commit b774e08
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
24 changes: 12 additions & 12 deletions readthedocs/projects/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,24 +314,24 @@

LOG_TEMPLATE = '(Build) [{project}:{version}] {msg}'

PROJECT_PK_REGEX = '(?:[-\w]+)'
PROJECT_SLUG_REGEX = '(?:[-\w]+)'
PROJECT_PK_REGEX = r'(?:[-\w]+)'
PROJECT_SLUG_REGEX = r'(?:[-\w]+)'

GITHUB_REGEXS = [
re.compile('github.com/(.+)/(.+)(?:\.git){1}$'),
re.compile('github.com/(.+)/(.+)'),
re.compile('github.com:(.+)/(.+)\.git$'),
re.compile(r'github.com/(.+)/(.+)(?:\.git){1}$'),
re.compile(r'github.com/(.+)/(.+)'),
re.compile(r'github.com:(.+)/(.+)\.git$'),
]
BITBUCKET_REGEXS = [
re.compile('bitbucket.org/(.+)/(.+)\.git$'),
re.compile('@bitbucket.org/(.+)/(.+)\.git$'),
re.compile('bitbucket.org/(.+)/(.+)/?'),
re.compile('bitbucket.org:(.+)/(.+)\.git$'),
re.compile(r'bitbucket.org/(.+)/(.+)\.git$'),
re.compile(r'@bitbucket.org/(.+)/(.+)\.git$'),
re.compile(r'bitbucket.org/(.+)/(.+)/?'),
re.compile(r'bitbucket.org:(.+)/(.+)\.git$'),
]
GITLAB_REGEXS = [
re.compile('gitlab.com/(.+)/(.+)(?:\.git){1}$'),
re.compile('gitlab.com/(.+)/(.+)'),
re.compile('gitlab.com:(.+)/(.+)\.git$'),
re.compile(r'gitlab.com/(.+)/(.+)(?:\.git){1}$'),
re.compile(r'gitlab.com/(.+)/(.+)'),
re.compile(r'gitlab.com:(.+)/(.+)\.git$'),
]
GITHUB_URL = (
'https://github.com/{user}/{repo}/'
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/search/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def parse_path_from_file(file_path):
# "path/index.html" => "path/index"
# "/path/index" => "path/index"
path = re.sub('/$', '/index', path)
path = re.sub('\.html$', '', path)
path = re.sub(r'\.html$', '', path)
path = re.sub('^/', '', path)

return path
Expand Down
4 changes: 2 additions & 2 deletions readthedocs/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ def USE_PROMOS(self): # noqa

# CORS
CORS_ORIGIN_REGEX_WHITELIST = (
'^http://(.+)\.readthedocs\.io$',
'^https://(.+)\.readthedocs\.io$'
r'^http://(.+)\.readthedocs\.io$',
r'^https://(.+)\.readthedocs\.io$',
)
# So people can post to their accounts
CORS_ALLOW_CREDENTIALS = True
Expand Down

0 comments on commit b774e08

Please sign in to comment.