Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Lib/http/cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,18 +391,18 @@ def __repr__(self):
return '<%s: %s>' % (self.__class__.__name__, self.OutputString())

def js_output(self, attrs=None):
import base64
import urllib.parse
# Print javascript
output_string = self.OutputString(attrs)
if _has_control_character(output_string):
raise CookieError("Control characters are not allowed in cookies")
# Base64-encode value to avoid template
# injection in cookie values.
output_encoded = base64.b64encode(output_string.encode('utf-8')).decode("ascii")
output_encoded = urllib.parse.quote(output_string, safe='', encoding='utf-8')
return """
<script type="text/javascript">
<!-- begin hiding
document.cookie = atob(\"%s\");
document.cookie = decodeURIComponent(\"%s\");
// end hiding -->
</script>
""" % (output_encoded,)
Expand Down
2 changes: 1 addition & 1 deletion Lib/imaplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ def login(self, user, password):
"""
typ, dat = self._simple_command('LOGIN', user, self._quote(password))
if typ != 'OK':
raise self.error(dat[-1])
raise self.error(dat[-1].decode('UTF-8', 'replace'))
self.state = 'AUTH'
return typ, dat

Expand Down
8 changes: 4 additions & 4 deletions Lib/json/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ def dump(obj, fp, *, skipkeys=False, ensure_ascii=True, check_circular=True,
If ``indent`` is a non-negative integer, then JSON array elements and
object members will be pretty-printed with that indent level. An indent
level of 0 will only insert newlines. ``None`` is the most compact
representation.
level of 0 will only insert newlines. ``None`` is the default and gives
a representation with no newlines inserted.
If specified, ``separators`` should be an ``(item_separator,
key_separator)`` tuple. The default is ``(', ', ': ')`` if *indent* is
Expand Down Expand Up @@ -207,8 +207,8 @@ def dumps(obj, *, skipkeys=False, ensure_ascii=True, check_circular=True,
If ``indent`` is a non-negative integer, then JSON array elements and
object members will be pretty-printed with that indent level. An indent
level of 0 will only insert newlines. ``None`` is the most compact
representation.
level of 0 will only insert newlines. ``None`` is the default and gives
a representation with no newlines inserted.
If specified, ``separators`` should be an ``(item_separator,
key_separator)`` tuple. The default is ``(', ', ': ')`` if *indent* is
Expand Down
3 changes: 2 additions & 1 deletion Lib/json/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def main():
infile = open(options.infile, encoding='utf-8')
try:
if options.json_lines:
objs = (json.loads(line) for line in infile)
lines = infile.readlines()
objs = (json.loads(line) for line in lines)
else:
objs = (json.load(infile),)
finally:
Expand Down
Loading
Loading