]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#1638033: add support for httponly on Cookie.Morsel
authorBenjamin Peterson <benjamin@python.org>
Sat, 6 Sep 2008 19:28:11 +0000 (19:28 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sat, 6 Sep 2008 19:28:11 +0000 (19:28 +0000)
Reviewer: Benjamin

Doc/library/cookie.rst
Lib/Cookie.py
Misc/ACKS
Misc/NEWS

index 346da5a1fd921eb8a5155db41f5b3dffeaf331ca..b6a85f5dffd7711dd837de6718c91264e5b28a39 100644 (file)
@@ -148,7 +148,7 @@ Morsel Objects
 --------------
 
 
-.. class:: Morsel()
+.. class:: Morsel
 
    Abstract a key/value pair, which has some :rfc:`2109` attributes.
 
@@ -162,9 +162,17 @@ Morsel Objects
    * ``max-age``
    * ``secure``
    * ``version``
+   * ``httponly``
+
+   The attribute :attr:`httponly` specifies that the cookie is only transfered
+   in HTTP requests, and is not accessible through JavaScript. This is intended
+   to mitigate some forms of cross-site scripting.
 
    The keys are case-insensitive.
 
+   .. versionadded:: 2.6
+      The :attr:`httponly` attribute was added.
+
 
 .. attribute:: Morsel.value
 
index e1eb7348bc693daf77010c56252052e8bb324f12..b2f7427aa94f734ab2a34285917fb11eb0b2c4fc 100644 (file)
@@ -408,6 +408,9 @@ class Morsel(dict):
     # For historical reasons, these attributes are also reserved:
     #   expires
     #
+    # This is an extension from Microsoft:
+    #   httponly
+    #
     # This dictionary provides a mapping from the lowercase
     # variant on the left to the appropriate traditional
     # formatting on the right.
@@ -417,6 +420,7 @@ class Morsel(dict):
                    "domain"      : "Domain",
                    "max-age" : "Max-Age",
                    "secure"      : "secure",
+                   "httponly"  : "httponly",
                    "version" : "Version",
                    }
 
@@ -499,6 +503,8 @@ class Morsel(dict):
                 RA("%s=%d" % (self._reserved[K], V))
             elif K == "secure":
                 RA(str(self._reserved[K]))
+            elif K == "httponly":
+                RA(str(self._reserved[K]))
             else:
                 RA("%s=%s" % (self._reserved[K], V))
 
index d231ece6a41e84f3128dfdbe6f002b4b6c43ceb4..ac8f6edd434914e54c61f36bccdff205d0ca4ec9 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -122,6 +122,7 @@ Nicolas Chauvat
 Michael Chermside
 Albert Chin-A-Young
 Adal Chiriliuc
+Matt Chisholm
 Tom Christiansen
 Vadim Chugunov
 David Cinege
index d06bfebd1dbaac6f181281a9ed750e63e99c3313..85adaeb06e3fd792dea579c0f7fd5c181b498d5b 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -56,6 +56,8 @@ C-API
 Library
 -------
 
+- Issue #1638033: Cookie.Morsel gained the httponly attribute.
+
 - Issue #3535: zipfile couldn't read some zip files larger than 2GB.
 
 - Issue #3776: Deprecate the bsddb package for removal in 3.0.