推荐学习书目
› 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
vtoexsir
V2EX  ›  Python

Python 为什么不使用 pickle 来直接序列化 requests.的 session.cookies 而常用 cookielib.LWPCookieJar 呢?

  •  
  •   vtoexsir · Feb 18, 2017 · 4078 views
    This topic created in 3517 days ago, the information mentioned may be changed or developed.
    sess=requests.session()
    resp=sess.get('http://www.so.com')
    f=open('cookiefile','wb')
    pickle.dump(resp.cookies,f)  #为什么很多代码都不是这样,而是使用 cookielib 的 LWPCookieJar?
    f.close()```
    
    5 replies  •  2017-02-18 16:06:38 +08:00
    013231
        1
    013231  
       Feb 18, 2017   ❤️ 1
    Warning The pickle module is not secure against erroneous or maliciously constructed data. Never unpickle data received from an untrusted or unauthenticated source.
    gouchaoer
        2
    gouchaoer  
       Feb 18, 2017 via Android   ❤️ 1
    这么说吧,除了 json 反序列化。。。。别的二进制的 /语言特性相关的,都不太安全
    phrack
        3
    phrack  
       Feb 18, 2017 via Android
    读文档不仔细了吧(๑`・ᴗ・´๑)
    skydiver
        4
    skydiver  
       Feb 18, 2017 via Android   ❤️ 1
    cookie 属于用户输入数据
    反序列化用户输入数据不安全
    vtoexsir
        5
    vtoexsir  
    OP
       Feb 18, 2017
    感谢各位热情回复!
    原来如此.
    英文读懂了 4 分!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2495 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 07:51 · PVG 15:51 · LAX 00:51 · JFK 03:51
    ♥ Do have faith in what you're doing.