def get_substring(data, boundary, offset, end):
    """ Retrieves the substring of ``data`` until the next ``boundary`` from a
    given offset to a until ``end``.
    """
    index = data.find(boundary, offset, end)
    if index == -1:
        return None, None
    return data[offset:index], index + len(boundary)