티스토리 수익 글 보기

티스토리 수익 글 보기

[1.2.X] Altered the behavior of URLField to avoid a potential DOS vec… · django/django@7268f8a · GitHub
Skip to content

Commit 7268f8a

Browse files
committed
[1.2.X] Altered the behavior of URLField to avoid a potential DOS vector, and to avoid potential leakage of local filesystem data. A security announcement will be made shortly.
Backport of r16760 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@16766 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent ac7c3a1 commit 7268f8a

File tree

3 files changed

+8
10
lines changed

3 files changed

+8
10
lines changed

django/db/models/fields/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ def formfield(self, **kwargs):
11191119
class URLField(CharField):
11201120
description = _("URL")
11211121

1122-
def __init__(self, verbose_name=None, name=None, verify_exists=True, **kwargs):
1122+
def __init__(self, verbose_name=None, name=None, verify_exists=False, **kwargs):
11231123
kwargs['max_length'] = kwargs.get('max_length', 200)
11241124
CharField.__init__(self, verbose_name, name, **kwargs)
11251125
self.validators.append(validators.URLValidator(verify_exists=verify_exists))

docs/ref/models/fields.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ shortcuts.
814814
``URLField``
815815
------------
816816

817-
.. class:: URLField([verify_exists=True, max_length=200, **options])
817+
.. class:: URLField([verify_exists=False, max_length=200, **options])
818818

819819
A :class:`CharField` for a URL. Has one extra optional argument:
820820

@@ -827,6 +827,12 @@ A :class:`CharField` for a URL. Has one extra optional argument:
827827
validating a URL being served by the same server will hang. This should not
828828
be a problem for multithreaded servers.
829829

830+
.. versionchanged:: 1.2
831+
832+
The default value of ``verify_exists`` has been changed to
833+
``False``. This argument should not be set to ``True`` because it
834+
has security and performance problems.
835+
830836
The admin represents this as an ``<input type="text">`` (a single-line input).
831837

832838
Like all :class:`CharField` subclasses, :class:`URLField` takes the optional

tests/modeltests/validation/tests.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,6 @@ def test_wrong_url_value_raises_error(self):
5252
mtv = ModelToValidate(number=10, name='Some Name', url='not a url')
5353
self.assertFieldFailsValidationWithMessage(mtv.full_clean, 'url', [u'Enter a valid value.'])
5454

55-
def test_correct_url_but_nonexisting_gives_404(self):
56-
mtv = ModelToValidate(number=10, name='Some Name', url='http://google.com/we-love-microsoft.html')
57-
self.assertFieldFailsValidationWithMessage(mtv.full_clean, 'url', [u'This URL appears to be a broken link.'])
58-
59-
def test_correct_url_value_passes(self):
60-
mtv = ModelToValidate(number=10, name='Some Name', url='http://www.djangoproject.com/')
61-
self.assertEqual(None, mtv.full_clean()) # This will fail if there's no Internet connection
62-
6355
def test_text_greater_that_charfields_max_length_eaises_erros(self):
6456
mtv = ModelToValidate(number=10, name='Some Name'*100)
6557
self.assertFailsValidation(mtv.full_clean, ['name',])

0 commit comments

Comments
 (0)