Opened 9 years ago
Last modified 9 years ago
#26378 closed Bug
Incorrect behavior in GenericIPAddressField with protocol='both', unpack_ipv4=False — at Version 3
Reported by: | bshen | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.8 |
Severity: | Normal | Keywords: | |
Cc: | bshen | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description (last modified by )
Basically, IPv4-mapped IPv6 addresses in the CIDR block ::ffff:0.0.0.0/104 are validated as invalid when unpack_ipv4=False, yet is valid when the first IPv4 octet is non-zero or when unpack_ipv4=True.
# my.app.models # Django==1.8.6 from django.db import models class TestIPNoUnpack(models.Model): ip = models.GenericIPAddressField(null=False, protocol='both', unpack_ipv4=False) class TestIPUnpack(models.Model): ip = models.GenericIPAddressField(null=False, protocol='both', unpack_ipv4=True) > python manage.py shell Python 2.7.6 (default, Sep 9 2014, 15:04:36) Type "copyright", "credits" or "license" for more information. IPython 4.0.1 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In [1]: from my.app.models import TestIPNoUnpack, TestIPUnpack In [2]: testipunpack = TestIPUnpack(ip='::ffff:0.0.0.0') In [3]: testipunpack.clean_fields() In [4]: testipunpack.ip Out[4]: '0.0.0.0' In [5]: testipnounpack = TestIPNoUnpack(ip='::ffff:0.0.0.0') In [6]: testipnounpack.clean_fields() --------------------------------------------------------------------------- ValidationError Traceback (most recent call last) <ipython-input-6-9a763f56e907> in <module>() ----> 1 testipnounpack.clean_fields() .../lib/python2.7/site-packages/django/db/models/base.pyc in clean_fields(self, exclude) 1194 1195 if errors: -> 1196 raise ValidationError(errors) 1197 1198 @classmethod ValidationError: {'ip': [u'Enter a valid IPv4 or IPv6 address.']} In [7]: testipnounpack2 = TestIPNoUnpack(ip='::ffff:0.255.255.255') In [8]: testipnounpack2.clean_fields() --------------------------------------------------------------------------- ValidationError Traceback (most recent call last) <ipython-input-8-e228d0855286> in <module>() ----> 1 testipnounpack2.clean_fields() .../lib/python2.7/site-packages/django/db/models/base.pyc in clean_fields(self, exclude) 1194 1195 if errors: -> 1196 raise ValidationError(errors) 1197 1198 @classmethod ValidationError: {'ip': [u'Enter a valid IPv4 or IPv6 address.']} In [9]: testipnounpack3 = TestIPNoUnpack(ip='::ffff:1.0.0.0') In [10]: testipnounpack3.clean_fields() In [11]: testipnounpack3.ip Out[11]: '::ffff:1.0.0.0'
Change History (2)
comment:1 by , 9 years ago
Cc: | added |
---|---|
Component: | Uncategorized → Database layer (models, ORM) |
Easy pickings: | set |
comment:3 by , 9 years ago
Description: | modified (diff) |
---|
Note:
See TracTickets
for help on using tickets.