Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def read_data(self, max_len=None):
""" Reads a dot-delimited SMTP DATA segment."""
data_length = 0
lines = []
while True:
line = yield from self.read_crlf_line(max_len=None)
access_log.debug("Data line read: %r", line)
if line == const.DATA_TERM:
break
if line.startswith(b'.'):
line = line[1:]
data_length += len(line)
if max_len and data_length > max_len:
access_log.error('Too much data: %i bytes', data_length)
raise errors.TooMuchDataError()
lines.append(line)
result = const.LINE_TERM.join(lines)
if max_len and len(result) >= max_len:
raise errors.TooMuchDataError()