Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

HTML error page does not escape template filename/URI

未关闭 适合新手
#442 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
html, python
领域
backend, security

调研方向

先定位 html_error_template(),以及在错误页面中呈现模板文件名或 URI 的代码。追踪该值如何进入 HTML 输出,然后添加一个使用包含 HTML 字符的 URI 的回归测试。生成的错误页面中的 URI 已转义即表示完成;运行相关的错误模板测试。

由索引模型根据 Issue 内容生成。

描述

Describe the bug

html_error_template() renders the template filename/URI without HTML escaping. If a template URI contains untrusted HTML, it is included verbatim in the generated error page rather than escaped.

To Reproduce

from mako.lookup import TemplateLookup

uri = "<img src=x onerror=alert(1)>"

lookup = TemplateLookup(format_exceptions=True)
lookup.put_string(uri, "${1/0}")

page = lookup.get_template(uri).render_unicode()

print(page)

Error

The generated error page contains:

<div class="location"><img src=x onerror=alert(1)>, line 1:</div>

I would expect the URI to be escaped.

Versions

  • OS: Linux
  • Python: 3.12
  • Mako: 1.4.3 and current main (14889bc)

Additional context

I reported this privately first. The security team reviewed it as a defense-in-depth issue and suggested opening a public issue or PR.

Happy to submit a fix and regression test.

主要语言
Python
星标
461
派生
104
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

sqlalchemy/mako 的其他 Issue

查看 sqlalchemy/mako 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。