A processing instruction with no target passes validation, then the builder prints invalid XML
维护者通常 4 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, node.js
- 领域
- backend, testing-qa
调研方向
从 XMLValidator 中处理处理指令的验证路径开始,然后将其对 <?x?> 和 <? ?> 的处理与 issue 中描述的 XML PI 语法进行比较。使用提供的 Node.js 示例检查 parser 和 builder 的行为。验证拒绝无效 target 的情况,或 parsing 跳过这些情况,从而使 builder 不会生成无效 XML,即为完成。
由索引模型根据 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 online tool?
- Have you checked the docs for helpful APIs and examples?
Description
Hello,
While fuzzing [email protected] (the latest version) with Termo, a fuzzer I'm developing, I found that XMLValidator accepts a processing instruction with no target name (<?>x?>). XMLParser then returns a node with an empty tag name, and XMLBuilder turns it into <></>, which is not XML:
// [email protected], Node.js v26.13.0
const { XMLValidator, XMLParser, XMLBuilder } = require('fast-xml-parser');
const options = { ignoreAttributes: false, preserveOrder: true };
const input = '<?>x?><r/>';
console.log(XMLValidator.validate(input)); // true
const parsed = new XMLParser(options).parse(input);
console.log(JSON.stringify(parsed)); // [{"":[{"#text":""}]},{"r":[]}]
const built = new XMLBuilder(options).build(parsed);
console.log(built); // <></><r></r>
console.log(XMLValidator.validate(built) === true); // false
Without a target (<?>) validation already fails as it should. With a body (<?>x?>) it passes. The XML spec requires a name right after <? (PI ::= '<?' PITarget (S ...)? '?>').
<? ?><r/> is similar: it validates, and parses into a node named "?", which the builder prints as <??>.
Expected: the validator rejects a processing instruction with no target (or else the parser skips it), so the builder never prints an element with an empty name.
Happy to test a fix against these inputs if it helps.
If you'd like me to keep fuzzing fast-xml-parser (other parts of the API, or re-checking after a fix), feel free to reach out. I'd be glad to keep working on it with you.
Thanks!
- 主要语言
- JavaScript
- 星标
- 3.1k
- 派生
- 410
- 平均合并
- 4 天 15 小时
- 30 天内合并 PR
- 8
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
NaturalIntelligence/fast-xml-parser 的其他 Issue
-
XMLValidator accepts double hyphens inside comments可能已有人在做 @Sskift 于 16 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 74/100
NaturalIntelligence/fast-xml-parser#903 · 3 条评论 ·
维护者通常 4 天内回复
-
XMLValidator accepts raw < and & in attribute values可能已有人在做 @jeromeyyy 于 14 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
NaturalIntelligence/fast-xml-parser#900 · 3 条评论 ·
维护者通常 4 天内回复
-
getMetaDataSymbol() declares a boxed Symbol可能已有人在做 @chiragbitoni 于 4 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
NaturalIntelligence/fast-xml-parser#890 · 1 条评论 ·
维护者通常 4 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 65/100
NaturalIntelligence/fast-xml-parser#888 · 2 条评论 ·
维护者通常 4 天内回复
-
ignoreDeclaration does not ignore lower case doctype declaration可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
NaturalIntelligence/fast-xml-parser#870 · 2 条评论 ·
维护者通常 4 天内回复
查看 NaturalIntelligence/fast-xml-parser 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 84/100
-
难度 2/5 1-3 小时 新手友好度 83/100
-
Extended search drops any query term that contains a line break可能已有人在做 @goranai 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 72/100
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复