Regex string escape properly

ghowardsit
Manuel Kaufmann 2018-11-28 14:33:00 +01:00
parent f0edd22bba
commit b774e081d7
3 changed files with 15 additions and 15 deletions

View File

@ -314,24 +314,24 @@ PROGRAMMING_LANGUAGES = (
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}/'

View File

@ -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

View File

@ -296,8 +296,8 @@ class CommunityBaseSettings(Settings):
# 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