fix: use Path.as_uri() in render_pdf.py for proper file URL escaping#87
Merged
Merged
Conversation
- Replace hand-stitched f"file://{html_path}" with html_path.as_uri()
so #, ?, Chinese characters, and other URL-special chars in file paths
are properly encoded (closes #81).
- Wrap browser lifecycle in try/finally so page.goto() failure doesn't
leak the Chromium process.
- Add CI smoke test covering paths with # and spaces.
2f2bbb8 to
d2d45fb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
Closes #81 —
render_pdf.py手拼file://URL 未做 URI 转义,路径含#、?、中文等字符时 Playwright 会误判为 fragment/query,返回net::ERR_FILE_NOT_FOUND。修改
scripts/render_pdf.pyfile_url = f"file://{html_path}"→html_path.as_uri()Path.as_uri()是标准库方法,按 RFC 8089 正确编码#→%23、?→%3F、空格 →%20等。try/finally原结构在
page.goto()抛错时跳过了browser.close()。改为try/finally确保异常路径也能关闭 Chromium 进程。.github/workflows/ci.ymlsmokejob 末尾新增一步:创建含#和空格的路径,运行完整md_to_pdf.pypipeline,验证 PDF 正确生成。不改的
md_to_pdf.py(子进程 argv 传参已正确处理特殊字符)test_remote_block.py/README.md/SKILL.md测试
CI
smoke会覆盖特殊字符路径集成测试。