1
0
mirror of https://github.com/django/django.git synced 2025-10-29 08:36:09 +00:00

Fixed #15018 -- Corrected the handling of LimitedStream under one edge case involving size restricted buffers and newlines. Thanks to xjdrew for the report, and aaugustin for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15222 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee
2011-01-16 07:31:35 +00:00
parent 1ca9e95d4e
commit b4f0921463
2 changed files with 29 additions and 2 deletions

View File

@@ -96,9 +96,10 @@ class LimitedStream(object):
return result
def readline(self, size=None):
while '\n' not in self.buffer or \
(size is not None and len(self.buffer) < size):
while '\n' not in self.buffer and \
(size is None or len(self.buffer) < size):
if size:
# since size is not None here, len(self.buffer) < size
chunk = self._read_limited(size - len(self.buffer))
else:
chunk = self._read_limited()