mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-09 08:00:52 +03:00
parent
41eb313e1c
commit
35f4908e48
|
@ -185,7 +185,7 @@ WRAPPING_PUNCTUATION = [('(', ')'), ('<', '>'), ('[', ']'), ('<', '>'),
|
||||||
('"', '"'), ("'", "'")]
|
('"', '"'), ("'", "'")]
|
||||||
word_split_re = re.compile(r'(\s+)')
|
word_split_re = re.compile(r'(\s+)')
|
||||||
simple_url_re = re.compile(r'^https?://\[?\w', re.IGNORECASE)
|
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+$')
|
simple_email_re = re.compile(r'^\S+@\S+\.\S+$')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from rest_framework.test import APIRequestFactory
|
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()
|
factory = APIRequestFactory()
|
||||||
|
|
||||||
|
@ -17,3 +17,39 @@ class TemplateTagTests(TestCase):
|
||||||
json_url = add_query_param(request, "format", "json")
|
json_url = add_query_param(request, "format", "json")
|
||||||
self.assertIn("q=%E6%9F%A5%E8%AF%A2", json_url)
|
self.assertIn("q=%E6%9F%A5%E8%AF%A2", json_url)
|
||||||
self.assertIn("format=json", 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)
|
Loading…
Reference in New Issue
Block a user