Skip to content

Commit 6ea1bf2

Browse files
committed
InvalidLinkBear: Disallow backslashes in URLs
There's no valid usecase for those, only false positives. Related: #691
1 parent 99e230b commit 6ea1bf2

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

bears/general/InvalidLinkBear.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def get_status_code(url, timeout):
4242
def find_links_in_file(file, timeout, ignore_regex):
4343
ignore_regex = re.compile(ignore_regex)
4444
regex = re.compile(
45-
r'((ftp|http)s?://[^.:\s_/?#[\]@]+\.(?:[^\s()\'\"<>|]+|'
46-
r'\([^\s()]*\))*)(?<!\.)(?<!,)')
45+
r'((ftp|http)s?://[^.:\s_/?#[\]@\\]+\.(?:[^\s()\'"<>|\\]+|'
46+
r'\([^\s()\'"<>|\\]*\))*)(?<!\.)(?<!,)')
4747
for line_number, line in enumerate(file):
4848
match = regex.search(line)
4949
if match:

tests/general/InvalidLinkBearTest.py

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def test_run(self):
9090
[httpbin](http://httpbin.org/status/200)
9191
|http://httpbin.org/status/200|
9292
<h3>Something http://httpbin.org/status/200</h3>
93+
repo=\\"http://httpbin.org/status/200\\"
9394
9495
# Not a link
9596
http://not a link dot com

0 commit comments

Comments
 (0)