推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
ayang23
V2EX  ›  Python

吐槽:Django EmailField 的验证尽然支持 abc@domain。com 这种域名,注意是句号啊,有木有?看了下 django 的源代码,发现确实如此。

  •  
  •   ayang23 ·
    ayang23 · Mar 25, 2013 · 4641 views
    This topic created in 4976 days ago, the information mentioned may be changed or developed.
    django.core.validators.py line 39:

    if not self.regex.search(smart_unicode(value)):
    raise ValidationError(self.message, code=self.code)

    句号直接验证通过了,我晕。
    5 replies  •  1970-01-01 08:00:00 +08:00
    workaholic
    workaholic
    Mar 25, 2013
    1
    bug
    c742435
    c742435
    Mar 25, 2013
    2
    具体不懂,但是任何一个现代桌面浏览器都支持句号代替dot
    xiaket
    xiaket
    Mar 25, 2013
    3
    要吐槽也贴真正对应的那部分嘛. 自己看看django.core.validators.py line 119行附近对idna的处理. 下面是我的测试代码, 应该能说明问题:

    >>> s = u"gmail。com"
    >>> s.encode("idna").decode("ascii")
    u'gmail.com'
    BOYPT
    BOYPT
    Mar 25, 2013
    4
    #feature
    swulling
    swulling
    Mar 25, 2013
    5
    这是feature不是bug
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1495 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 15:06 · PVG 23:06 · LAX 07:06 · JFK 10:06
    ♥ Do have faith in what you're doing.