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

Clone references before escaping?

未关闭
#4 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
28/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
perl
领域
backend, security

调研方向

从 issue 中描述的 _encode 入口点开始,跟踪它如何递归处理模板参数和引用。验证涉及 Dancer::Template::Abstract 的示例,并确认转义不再修改原始设置或 $foo 引用;如果存在相关的现有测试,请添加或运行它们。

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

描述

As originally discovered in http://www.backup-manager.org/pipermail/dancer-users/2012-April/002424.html :

When automatic_escaping is enabled, we recursively encode HTML entities in template params, following references.

Since the app's settings are automatically passed to the template by Dancer::Template::Abstract, stored as a reference to the real settings hashref, we can inadvertently go HTML-encoding stuff in the app's actual settings.

A partial fix is for Dancer to clone the settings rather than storing an actual reference, but of course that still means the problem can occur in other cases.

For example:

get '/' => sub {
    my $foo = { foo => '<Foo>' };
    my $html = template 'bar', { foo => $foo };
    # $foo->{foo} has been changed to &lt;Foo&gt;
};

Probably a safer fix is for _encode to automatically clone any reference it's about to change before making changes. This would need some refactoring in _encode to assume that it's starting with a hashref (which it will be) and to pass on both the key and the value each time, rather than simply passing the reference to the value when recursing.

主要语言
Perl
星标
4
派生
3
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

相似的 Issue

更多 Perl Issue

把新 issue 发到你的邮箱

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