Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
35f4908e
Commit
35f4908e
authored
Feb 09, 2014
by
Artem Mezhenin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
issue #1386
* regex for matching URLs was rewritten * added unittests
parent
41eb313e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
2 deletions
+39
-2
rest_framework/templatetags/rest_framework.py
+1
-1
rest_framework/tests/test_templatetags.py
+38
-1
No files found.
rest_framework/templatetags/rest_framework.py
View file @
35f4908e
...
...
@@ -185,7 +185,7 @@ WRAPPING_PUNCTUATION = [('(', ')'), ('<', '>'), ('[', ']'), ('<', '>'),
(
'"'
,
'"'
),
(
"'"
,
"'"
)]
word_split_re
=
re
.
compile
(
r'(\s+)'
)
simple_url_re
=
re
.
compile
(
r'^https?://\[?\w'
,
re
.
IGNORECASE
)
simple_url_2_re
=
re
.
compile
(
r'^
www\.|^(?!http)\w[^@\[\]]+\.(com|edu|gov|int|mil|net|org)
$'
,
re
.
IGNORECASE
)
simple_url_2_re
=
re
.
compile
(
r'^
\w[^@\[\]\:\/,]+\.(com|edu|gov|int|mil|net|org)(:\d{2,5})?(/(\w[^@\[\]\:\,]+)?)?
$'
,
re
.
IGNORECASE
)
simple_email_re
=
re
.
compile
(
r'^\S+@\S+\.\S+$'
)
...
...
rest_framework/tests/test_templatetags.py
View file @
35f4908e
...
...
@@ -2,7 +2,7 @@
from
__future__
import
unicode_literals
from
django.test
import
TestCase
from
rest_framework.test
import
APIRequestFactory
from
rest_framework.templatetags.rest_framework
import
add_query_param
from
rest_framework.templatetags.rest_framework
import
add_query_param
,
urlize_quoted_links
factory
=
APIRequestFactory
()
...
...
@@ -17,3 +17,39 @@ class TemplateTagTests(TestCase):
json_url
=
add_query_param
(
request
,
"format"
,
"json"
)
self
.
assertIn
(
"q=
%
E6
%9
F
%
A5
%
E8
%
AF
%
A2"
,
json_url
)
self
.
assertIn
(
"format=json"
,
json_url
)
class
Issue1386Tests
(
TestCase
):
"""
Covers #1386
"""
def
test_issue_1386
(
self
):
"""
Test function urlize_quoted_links with different args
"""
correct_urls
=
[
"asdf.com/zxvc"
,
"asdf.net"
,
"www.as_df.org"
,
"as.d8f.ghj8.gov"
,
"www.a-op.s.d.edu/asdf/dfff_908/"
,
"cd8fr.com:80/hello"
,
"cdfr.com:808/hello"
,
"cdfr.com:8080/hello"
,
"cdfr.com:44808/hello/asdf/"
,
]
for
i
in
correct_urls
:
res
=
urlize_quoted_links
(
i
)
self
.
assertGreater
(
len
(
res
),
len
(
i
))
self
.
assertIn
(
i
,
res
)
incorrect_urls
=
[
"mailto://asdf@fdf.com"
,
"asdf://asdf.com"
,
"asdf.netnet"
,
"asdf:[/p]zxcv.com"
# example from issue #1386
]
for
i
in
incorrect_urls
:
res
=
urlize_quoted_links
(
i
)
self
.
assertEqual
(
i
,
res
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment