Changes between Initial Version and Version 3 of Ticket #26378


Ignore:
Timestamp:
Mar 18, 2016, 7:02:02 PM (9 years ago)
Author:
Tim Graham
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #26378

    • Property Cc bshen added
    • Property Component UncategorizedDatabase layer (models, ORM)
    • Property Easy pickings set
  • Ticket #26378 – Description

    initial v3  
    1 https://dpaste.de/EMJa
     1Basically, 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.
    22
    3 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.
     3{{{ #!python
     4# my.app.models
     5# Django==1.8.6
     6from django.db import models
     7class TestIPNoUnpack(models.Model):
     8    ip = models.GenericIPAddressField(null=False, protocol='both', unpack_ipv4=False)
     9
     10
     11class TestIPUnpack(models.Model):
     12    ip = models.GenericIPAddressField(null=False, protocol='both', unpack_ipv4=True)
     13
     14
     15
     16> python manage.py shell
     17Python 2.7.6 (default, Sep  9 2014, 15:04:36)
     18Type "copyright", "credits" or "license" for more information.
     19
     20IPython 4.0.1 -- An enhanced Interactive Python.
     21?         -> Introduction and overview of IPython's features.
     22%quickref -> Quick reference.
     23help      -> Python's own help system.
     24object?   -> Details about 'object', use 'object??' for extra details.
     25
     26In [1]: from my.app.models import TestIPNoUnpack, TestIPUnpack
     27
     28In [2]: testipunpack = TestIPUnpack(ip='::ffff:0.0.0.0')
     29
     30In [3]: testipunpack.clean_fields()
     31
     32In [4]: testipunpack.ip
     33Out[4]: '0.0.0.0'
     34
     35In [5]: testipnounpack = TestIPNoUnpack(ip='::ffff:0.0.0.0')
     36
     37In [6]: testipnounpack.clean_fields()
     38---------------------------------------------------------------------------
     39ValidationError                           Traceback (most recent call last)
     40<ipython-input-6-9a763f56e907> in <module>()
     41----> 1 testipnounpack.clean_fields()
     42
     43.../lib/python2.7/site-packages/django/db/models/base.pyc in clean_fields(self, exclude)
     44   1194
     45   1195         if errors:
     46-> 1196             raise ValidationError(errors)
     47   1197
     48   1198     @classmethod
     49
     50ValidationError: {'ip': [u'Enter a valid IPv4 or IPv6 address.']}
     51
     52In [7]: testipnounpack2 = TestIPNoUnpack(ip='::ffff:0.255.255.255')
     53
     54In [8]: testipnounpack2.clean_fields()
     55---------------------------------------------------------------------------
     56ValidationError                           Traceback (most recent call last)
     57<ipython-input-8-e228d0855286> in <module>()
     58----> 1 testipnounpack2.clean_fields()
     59
     60.../lib/python2.7/site-packages/django/db/models/base.pyc in clean_fields(self, exclude)
     61   1194
     62   1195         if errors:
     63-> 1196             raise ValidationError(errors)
     64   1197
     65   1198     @classmethod
     66
     67ValidationError: {'ip': [u'Enter a valid IPv4 or IPv6 address.']}
     68
     69In [9]: testipnounpack3 = TestIPNoUnpack(ip='::ffff:1.0.0.0')
     70
     71In [10]: testipnounpack3.clean_fields()
     72
     73In [11]: testipnounpack3.ip
     74Out[11]: '::ffff:1.0.0.0'
     75
     76}}}
Back to Top