Skip to content

Commit b774e08

Browse files
committed
Regex string escape properly
1 parent f0edd22 commit b774e08

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

readthedocs/projects/constants.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -314,24 +314,24 @@
314314

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

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

320320
GITHUB_REGEXS = [
321-
re.compile('github.com/(.+)/(.+)(?:\.git){1}$'),
322-
re.compile('github.com/(.+)/(.+)'),
323-
re.compile('github.com:(.+)/(.+)\.git$'),
321+
re.compile(r'github.com/(.+)/(.+)(?:\.git){1}$'),
322+
re.compile(r'github.com/(.+)/(.+)'),
323+
re.compile(r'github.com:(.+)/(.+)\.git$'),
324324
]
325325
BITBUCKET_REGEXS = [
326-
re.compile('bitbucket.org/(.+)/(.+)\.git$'),
327-
re.compile('@bitbucket.org/(.+)/(.+)\.git$'),
328-
re.compile('bitbucket.org/(.+)/(.+)/?'),
329-
re.compile('bitbucket.org:(.+)/(.+)\.git$'),
326+
re.compile(r'bitbucket.org/(.+)/(.+)\.git$'),
327+
re.compile(r'@bitbucket.org/(.+)/(.+)\.git$'),
328+
re.compile(r'bitbucket.org/(.+)/(.+)/?'),
329+
re.compile(r'bitbucket.org:(.+)/(.+)\.git$'),
330330
]
331331
GITLAB_REGEXS = [
332-
re.compile('gitlab.com/(.+)/(.+)(?:\.git){1}$'),
333-
re.compile('gitlab.com/(.+)/(.+)'),
334-
re.compile('gitlab.com:(.+)/(.+)\.git$'),
332+
re.compile(r'gitlab.com/(.+)/(.+)(?:\.git){1}$'),
333+
re.compile(r'gitlab.com/(.+)/(.+)'),
334+
re.compile(r'gitlab.com:(.+)/(.+)\.git$'),
335335
]
336336
GITHUB_URL = (
337337
'https://github.com/{user}/{repo}/'

readthedocs/search/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def parse_path_from_file(file_path):
103103
# "path/index.html" => "path/index"
104104
# "/path/index" => "path/index"
105105
path = re.sub('/$', '/index', path)
106-
path = re.sub('\.html$', '', path)
106+
path = re.sub(r'\.html$', '', path)
107107
path = re.sub('^/', '', path)
108108

109109
return path

readthedocs/settings/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ def USE_PROMOS(self): # noqa
296296

297297
# CORS
298298
CORS_ORIGIN_REGEX_WHITELIST = (
299-
'^http://(.+)\.readthedocs\.io$',
300-
'^https://(.+)\.readthedocs\.io$'
299+
r'^http://(.+)\.readthedocs\.io$',
300+
r'^https://(.+)\.readthedocs\.io$',
301301
)
302302
# So people can post to their accounts
303303
CORS_ALLOW_CREDENTIALS = True

0 commit comments

Comments
 (0)