Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent endless loop and index out of range in pagination #798

Merged
merged 1 commit into from
Feb 11, 2019
Merged
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
7 changes: 4 additions & 3 deletions weasyprint/layout/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,14 +765,15 @@ def remake_page(index, context, root_box, html, cascaded_styles,
'anchors': [],
'content_lookups': [],
}
# Setting content_changed to True ensures remake.
# If resume_at is None (last page) it must be False to prevent endless
# loops and list index out of range (see #794).
remake_state['content_changed'] = resume_at is not None
# page_state is already a deepcopy
item = resume_at, next_page, right_page, page_state, remake_state
if index + 1 >= len(page_maker):
# content_changed must be False otherwise: enldess loop
page_maker.append(item)
else:
# content_changed must be True otherwise: no remake
remake_state['content_changed'] = True
page_maker[index + 1] = item

return page, resume_at
Expand Down