Skip to content

[Bug] Fix Malformed Table Crash#74

Open
dfop02 wants to merge 1 commit intorelease/1.1.5from
bug/malformed-table
Open

[Bug] Fix Malformed Table Crash#74
dfop02 wants to merge 1 commit intorelease/1.1.5from
bug/malformed-table

Conversation

@dfop02
Copy link
Copy Markdown
Owner

@dfop02 dfop02 commented Mar 22, 2026

Description

Problem

get_table_dimensions() was underestimating the number of columns when rowspan shifts cells into the next rows.
This caused handle_table() to access columns outside the grid, raising:

IndexError: list index out of range

Solution

Updated get_table_dimensions() to simulate real table layout using a used_cells grid, accounting for both rowspan and colspan.

Also added a small bounds check in handle_table() for extra safety.

Tests

Added a regression test for malformed tables where rowspan causes column overflow, ensuring:

  • no exception is raised
  • correct dimensions are created
  • cells are placed in the right columns

Impact

  • Fixes crashes on malformed/complex tables
  • Improves accuracy of table rendering

Issue Reference

Fixes #70

Checklist Before Requesting a Review

  • I have performed a self-review of my code.
  • My code follows the project's coding style and guidelines.
  • I have run tests and verified that all existing and new tests pass.
  • I have added new tests to cover my changes.

@dfop02 dfop02 self-assigned this Mar 22, 2026
@dfop02 dfop02 added the bug Something isn't working label Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant