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
dbd993d1
Commit
dbd993d1
authored
Feb 13, 2014
by
Artem Mezhenin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrapper for smart_urlquote, issue #1386
parent
08ec2326
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
rest_framework/templatetags/rest_framework.py
+13
-6
No files found.
rest_framework/templatetags/rest_framework.py
View file @
dbd993d1
...
@@ -189,6 +189,17 @@ simple_url_2_re = re.compile(r'^www\.|^(?!http)\w[^@]+\.(com|edu|gov|int|mil|net
...
@@ -189,6 +189,17 @@ simple_url_2_re = re.compile(r'^www\.|^(?!http)\w[^@]+\.(com|edu|gov|int|mil|net
simple_email_re
=
re
.
compile
(
r'^\S+@\S+\.\S+$'
)
simple_email_re
=
re
.
compile
(
r'^\S+@\S+\.\S+$'
)
def
smart_urlquote_wrapper
(
matched_url
):
"""
Simple wrapper for smart_urlquote. ValueError("Invalid IPv6 URL") can
be raised here, see issue #1386
"""
try
:
return
smart_urlquote
(
matched_url
)
except
ValueError
:
return
None
@register.filter
@register.filter
def
urlize_quoted_links
(
text
,
trim_url_limit
=
None
,
nofollow
=
True
,
autoescape
=
True
):
def
urlize_quoted_links
(
text
,
trim_url_limit
=
None
,
nofollow
=
True
,
autoescape
=
True
):
"""
"""
...
@@ -232,13 +243,9 @@ def urlize_quoted_links(text, trim_url_limit=None, nofollow=True, autoescape=Tru
...
@@ -232,13 +243,9 @@ def urlize_quoted_links(text, trim_url_limit=None, nofollow=True, autoescape=Tru
url
=
None
url
=
None
nofollow_attr
=
' rel="nofollow"'
if
nofollow
else
''
nofollow_attr
=
' rel="nofollow"'
if
nofollow
else
''
if
simple_url_re
.
match
(
middle
):
if
simple_url_re
.
match
(
middle
):
url
=
smart_urlquote
(
middle
)
url
=
smart_urlquote
_wrapper
(
middle
)
elif
simple_url_2_re
.
match
(
middle
):
elif
simple_url_2_re
.
match
(
middle
):
# ValueError("Invalid IPv6 URL") can be raised here, see issue #1386
url
=
smart_urlquote_wrapper
(
'http://
%
s'
%
middle
)
try
:
url
=
smart_urlquote
(
'http://
%
s'
%
middle
)
except
ValueError
:
pass
elif
not
':'
in
middle
and
simple_email_re
.
match
(
middle
):
elif
not
':'
in
middle
and
simple_email_re
.
match
(
middle
):
local
,
domain
=
middle
.
rsplit
(
'@'
,
1
)
local
,
domain
=
middle
.
rsplit
(
'@'
,
1
)
try
:
try
:
...
...
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