System.Xml: XSD allows patterns that should be invalid
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start by tracing how System.Xml validates xs:pattern values and how its regex handling differs from the XML regex dialect described in the linked specification. The report provides two reproductions involving grouping and backreferences; use them to identify the relevant validation tests and confirm the expected schema errors. Done means those patterns are rejected while valid XML regex patterns continue to work.
由索引模型根据 Issue 内容生成。
描述
Description
XSD schemas allows use of regex string that are not valid according to the XML regex dialect but are valid in .NET regex dialect. Some examples include:
- Backtracking
- Various grouping constructs
- Look arounds
Reproduction Steps
using System;
using System.IO;
using System.Xml;
using System.Xml.Schema;
Check("(?<x>y)", "<id>y</id>"); // '?' should not be allowed to follow '('. Instead this creates a named group.
Check("(y)\\2", "<id>yy</id>"); // "\\2" should be an invalid escape sequence. Instead this creates a back reference
static void Check(string pattern, string xml)
{
string xsd = $@"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<xs:element name='id'>
<xs:simpleType>
<xs:restriction base='xs:string'>
<xs:pattern value='{pattern}'/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>";
var settings = new XmlReaderSettings
{
ValidationType = ValidationType.Schema
};
settings.Schemas.Add(null, XmlReader.Create(new StringReader(xsd)));
int errors = 0;
settings.ValidationEventHandler += (_, e) =>
{
if (e.Severity == XmlSeverityType.Error)
errors++;
else
throw e.Exception;
};
using var reader = XmlReader.Create(new StringReader(xml), settings);
while (reader.Read()) { }
Console.WriteLine(
$"{pattern,-12} {xml,-36} {(errors == 0 ? "VALID" : "INVALID")}");
}
Expected behavior
Exceptions or output INVALID for all three since the patterns are not valid according to xml spec?
Actual behavior
Both checks outputs VALID.
Regression?
Not what i can find
Known Workarounds
No response
Configuration
No response
Other information
System.Xml has contribution bar "". I would expect these issues to be classified as edge-cased and the bug report to closed as won't fix, but at least it is logged.
- 主要语言
- C#
- 星标
- 18.4k
- 派生
- 5.8k
- 平均合并
- 2 天 14 小时
- 30 天内合并 PR
- 585
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
dotnet/runtime 的其他 Issue
-
.NET 10 single-file publishing silently produces empty executables above 2 GiB due to integer overflow in BinaryUtils.WriteToStream可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭area-Host untriaged
难度 2/5 1-3 小时 新手友好度 68/100
dotnet/runtime#137187 · 3 条评论 ·
维护者通常 1 天内回复
-
ImmutableSortedSet<T>.Builder: enumerating through IEnumerable<T> doesn't throw on modification and can return wrong items可能已有人在做 @aw0lid 于 1 天前认领。 未关闭area-System.Collections
难度 2/5 1-3 小时 新手友好度 78/100
dotnet/runtime#137167 · 1 条评论 ·
维护者通常 1 天内回复
-
DbTransaction.SupportsSavepoints docs say Release/ReleaseAsync are expected to throw, but they are no-ops by design可能已有人在做 @alaricd 于 5 天前认领。 未关闭area-System.Transactions untriaged
难度 2/5 1-3 小时 新手友好度 72/100
dotnet/runtime#137040 · 1 条评论 ·
维护者通常 1 天内回复
-
FileSystemGlobbing: Matcher throws ArgumentOutOfRangeException when the rootDir is the same value as the file可能已有人在做 @makazeu 于 5 天前认领。 未关闭area-Extensions-FileSystem
难度 2/5 1-3 小时 新手友好度 78/100
dotnet/runtime#136989 · 1 条评论 ·
维护者通常 1 天内回复
-
Configuration binder source generator emits unqualified List<T> when binding arrays without implicit usings可能已有人在做 @makazeu 于 5 天前认领。 未关闭area-Extensions-Configuration bug source-generator
难度 2/5 1-3 小时 新手友好度 78/100
dotnet/runtime#136972 · 1 条评论 ·
维护者通常 1 天内回复
相似的 Issue
-
Skills未关闭wayfinder:grilling
难度 2/5 1-3 小时 新手友好度 64/100
DigiBanks99/lopen#37 ·
-
难度 2/5 1-3 小时 新手友好度 66/100
sebastienros/fluid#1273 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 73/100
KnifeLemon/Filee#1344 ·
维护者通常 1 天内回复