Repository navigation
https://github.com/jackdewinter/pymarkdown/issues/1706 - #1715
Conversation
Reviewer's GuideThis PR strengthens table parsing regression coverage and adjusts MD055 end-token handling while making unhandled tokenization errors actionable by including the file being scanned or fixed; associated tests, generated artifacts, and changelog entries are updated. Sequence diagram for file-specific tokenization error reportingsequenceDiagram
participant Scanner
participant TokenizedMarkdown
participant FileScanHelper
participant Caller
Scanner->>TokenizedMarkdown: transform()
TokenizedMarkdown-->>FileScanHelper: BadTokenizationError(UNHANDLED_EXCEPTION_TEXT)
FileScanHelper->>FileScanHelper: __scan_file() or __fix_specific_file_with_error_handling()
FileScanHelper-->>Caller: BadTokenizationError(file-specific message)
Flow diagram for MD055 table end-token handlingflowchart TD
A[MD055 receives EndMarkdownToken] --> B{Table item token?}
B -->|Yes| C[Store extracted whitespace]
B -->|No| D{Table header or row token?}
D -->|Yes| E[Determine trailing pipe]
E --> F[Check table row]
F --> G{Table header?}
G -->|Yes| H[Check separator row]
G -->|No| I[Finish token handling]
D -->|No| I
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="pymarkdown/file_scan_helper.py" line_range="291" />
<code_context>
+ ):
+ raise BadTokenizationError(
+ f"An unhandled error occurred processing the '{next_file_name}' file."
+ ) from this_exception
raise
</code_context>
<issue_to_address>
**Untrusted filenames forge error output**
When an attacker-controlled filename contains newline or terminal control characters and scanning or fixing that file hits an unhandled tokenization error, the filename is interpolated without escaping and reaches raw stderr output, so newlines or terminal control sequences forge log lines or alter terminal display when the error is printed.
Escape control characters in filenames before including them in displayed errors.
Also at `pymarkdown/file_scan_helper.py:372`.
</issue_to_address>| ): | ||
| raise BadTokenizationError( | ||
| f"An unhandled error occurred processing the '{next_file_name}' file." | ||
| ) from this_exception |
There was a problem hiding this comment.
🟡 Medium · Untrusted filenames forge error output
When an attacker-controlled filename contains newline or terminal control characters and scanning or fixing that file hits an unhandled tokenization error, the filename is interpolated without escaping and reaches raw stderr output, so newlines or terminal control sequences forge log lines or alter terminal display when the error is printed.
Escape control characters in filenames before including them in displayed errors.
Also at pymarkdown/file_scan_helper.py:372.
Prompt for AI agents
In `pymarkdown/file_scan_helper.py` at line 291:
**Untrusted filenames forge error output**
When an attacker-controlled filename contains newline or terminal control characters and scanning or fixing that file hits an unhandled tokenization error, the filename is interpolated without escaping and reaches raw stderr output, so newlines or terminal control sequences forge log lines or alter terminal display when the error is printed.
Escape control characters in filenames before including them in displayed errors.
Also at `pymarkdown/file_scan_helper.py:372`.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1715 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 208 208
Lines 25420 25427 +7
Branches 3209 3211 +2
=========================================
+ Hits 25420 25427 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary by Sourcery
Improve Markdown table parsing and make tokenization failures identify the file being processed.
New Features:
Bug Fixes:
Build:
Documentation:
Tests:
Chores: