mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Udpate http from 3.14.4
This commit is contained in:
1 parent
3acab100f4
commit
a40cad8920
1 file changed
+20
-4
Vendored
+20
-4
@@ -337,9 +337,16 @@ class Morsel(dict):
|
||||
key = key.lower()
|
||||
if key not in self._reserved:
|
||||
raise CookieError("Invalid attribute %r" % (key,))
|
||||
if _has_control_character(key, val):
|
||||
raise CookieError("Control characters are not allowed in "
|
||||
f"cookies {key!r} {val!r}")
|
||||
data[key] = val
|
||||
dict.update(self, data)
|
||||
|
||||
def __ior__(self, values):
|
||||
self.update(values)
|
||||
return self
|
||||
|
||||
def isReservedKey(self, K):
|
||||
return K.lower() in self._reserved
|
||||
|
||||
@@ -365,9 +372,15 @@ class Morsel(dict):
|
||||
}
|
||||
|
||||
def __setstate__(self, state):
|
||||
self._key = state['key']
|
||||
self._value = state['value']
|
||||
self._coded_value = state['coded_value']
|
||||
key = state['key']
|
||||
value = state['value']
|
||||
coded_value = state['coded_value']
|
||||
if _has_control_character(key, value, coded_value):
|
||||
raise CookieError("Control characters are not allowed in cookies "
|
||||
f"{key!r} {value!r} {coded_value!r}")
|
||||
self._key = key
|
||||
self._value = value
|
||||
self._coded_value = coded_value
|
||||
|
||||
def output(self, attrs=None, header="Set-Cookie:"):
|
||||
return "%s %s" % (header, self.OutputString(attrs))
|
||||
@@ -379,13 +392,16 @@ class Morsel(dict):
|
||||
|
||||
def js_output(self, attrs=None):
|
||||
# Print javascript
|
||||
output_string = self.OutputString(attrs)
|
||||
if _has_control_character(output_string):
|
||||
raise CookieError("Control characters are not allowed in cookies")
|
||||
return """
|
||||
<script type="text/javascript">
|
||||
<!-- begin hiding
|
||||
document.cookie = \"%s\";
|
||||
// end hiding -->
|
||||
</script>
|
||||
""" % (self.OutputString(attrs).replace('"', r'\"'))
|
||||
""" % (output_string.replace('"', r'\"'))
|
||||
|
||||
def OutputString(self, attrs=None):
|
||||
# Build up our result
|
||||
|
||||
Reference in new issue
Block a user