XMLValidator accepts raw < and & in attribute values
维护者通常 3 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript
- 领域
- data
调研方向
从验证器的 validateAttributeString 函数开始。issue 中说,该函数接收属性令牌扫描器传来的带引号的值,但没有检查其中是否含有原始的 '<' 或格式错误的 '&' 引用。将 issue 中的三个输入分别通过 XMLValidator.validate 和 parse(xml, true) 运行,以确认当前行为。完成标准是:前两个输入未通过验证,& 对照用例仍然通过,且现有测试全部保持通过。
由索引模型根据 Issue 内容生成。
描述
- Are you running the latest version?
- Have you included sample input, output, error, and expected output?
- Have you checked if you are using correct configuration?
- Did you try the online tool?
- Have you checked the docs for helpful APIs and examples?
Description
On 5.11.2 (current master at cf66a9658004553bc740616e6c7a4912e7e9aab6), XMLValidator accepts raw ampersands and less-than signs inside quoted attribute values. XML 1.0's AttValue grammar excludes both literal characters there; an ampersand must begin a reference. This concerns attribute values, whereas #214 reported a stray ampersand in element text.
Input
<a x="&"/>
<a x="<"/>
<a x="&"/>
The last input is a valid control.
Code
const { XMLParser, XMLValidator } = require('fast-xml-parser');
for (const xml of ['<a x="&"/>', '<a x="<"/>', '<a x="&"/>']) {
console.log(xml, XMLValidator.validate(xml));
}
console.log(new XMLParser({ ignoreAttributes: false }).parse('<a x="&"/>', true));
Output
XMLValidator.validate returns true for all three inputs. Parsing the raw-ampersand input with validation enabled returns { a: { '@_x': '&' } }. The official online validator also reports "Valid XML" for both malformed inputs.
Expected data
The first two inputs should return a validation error, and parse(xml, true) should reject them. The escaped control should remain valid. The attribute token scanner extracts the quoted value, but validateAttributeString does not check that value for raw '<' or malformed '&' references.
Would you like to work on this issue?
- Yes
- No
- 主要语言
- JavaScript
- 星标
- 3.1k
- 派生
- 404
- 平均合并
- 2 天 1 小时
- 30 天内合并 PR
- 5
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
NaturalIntelligence/fast-xml-parser 的其他 Issue
-
XMLValidator accepts double hyphens inside comments可能已有人在做 @Sskift 于 5 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 74/100
NaturalIntelligence/fast-xml-parser#903 · 3 条评论 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
NaturalIntelligence/fast-xml-parser#890 · 1 条评论 ·
维护者通常 3 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 65/100
NaturalIntelligence/fast-xml-parser#888 · 2 条评论 ·
维护者通常 3 天内回复
-
ignoreDeclaration does not ignore lower case doctype declaration可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
NaturalIntelligence/fast-xml-parser#870 · 2 条评论 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 56/100
NaturalIntelligence/fast-xml-parser#914 · 1 条评论 ·
维护者通常 3 天内回复
查看 NaturalIntelligence/fast-xml-parser 的全部 Issue
相似的 Issue
-
bug 🐛
难度 2/5 1-3 小时 新手友好度 78/100
comunica/comunica#1960 · 1 条评论 ·
维护者通常 1 天内回复
-
Waiting for: Product Owner
难度 2/5 1-3 小时 新手友好度 76/100
getsentry/sentry-javascript#26203 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
bytedance/flowgram.ai#1235 ·
维护者通常 1 天内回复