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

Allow form feed characters in attributes

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

还没有人认领这个 Issue。

评估

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

调研方向

从 Tokenizer::quotedAttributeValue() 开始,使用包含换页符的 img alt 属性重现该问题,并将 HTML5 输出与 DOMDocument 进行比较。追踪换页符之后的文本为何会被丢弃,然后添加覆盖测试,展示该字符会像原生 DOM 输出中一样被保留。

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

描述

Tokenizer::quotedAttributeValue() has special handling for form feed characters.
(This used to also include newlines and tabs but was removed in https://github.com/Masterminds/html5-php/commit/8785fc5775df52dd4a6b63677ebd08f8301ffdcc.)

Because of this, if an attribute contains a form feed, everything after this character is ignored.

This creates a discrepancy between masterminds/html5 and the native DOM extension:

$html = "<img src='foo.png' alt='before \f after'>";

$html5 = new HTML5();
$dom = $html5->loadHTML($html);
echo $html5->saveHTML($dom);
// <img src="foo.png" alt="before ">

$dom = new DOMDocument();
$dom->loadHTML($html);
echo $dom->saveHTML();
// <img src="foo.png" alt="before  after">

This HTML containing a form feed character in the alt attribute is valid according to https://validator.w3.org/:

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<img src="foo.png" alt=" foo">
</body>
</html>
主要语言
HTML
星标
1.8k
派生
123
PR 合并指标
30 天内没有已合并 PR

环境准备

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

从这里开始

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

Masterminds/html5-php 的其他 Issue

查看 Masterminds/html5-php 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 发到你的邮箱

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