Skip to content

Fix IndexError padding a nested empty table#445

Open
santhreal wants to merge 1 commit into
Alir3z4:masterfrom
santhreal:fix/pad-tables-empty-nested-indexerror
Open

Fix IndexError padding a nested empty table#445
santhreal wants to merge 1 commit into
Alir3z4:masterfrom
santhreal:fix/pad-tables-empty-nested-indexerror

Conversation

@santhreal

Copy link
Copy Markdown

With pad_tables enabled, each table is reformatted by reformat_table(), which sizes its columns via lines[0].split("|"). A nested table (e.g. <table><table></table></table>, common in email/layout HTML) emits two adjacent pad markers with no rows buffered between them, so reformat_table receives an empty list and raises IndexError: list index out of range.

An empty buffer has no rows to pad, so return early. A single empty <table></table> was already fine; only the nested case produced the empty inner buffer.

Added test_reformat_table_empty_returns_empty and test_pad_tables_nested_empty_table.

pad_tables reformats each table via reformat_table(), which indexes lines[0]
to size columns. A nested table emits two adjacent pad markers with no rows
buffered between them, so reformat_table receives an empty list and raises
IndexError on valid (e.g. email) HTML. An empty buffer has nothing to pad,
so return early.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant