System.Xml: XSD allows patterns that should be invalid
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- C#
- Stelle
- 18.4k
- Fork
- 5.8k
- Merge medio
- 2g 14h
- PR unite (30g)
- 585
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di dotnet/runtime
-
.NET 10 single-file publishing silently produces empty executables above 2 GiB due to integer overflow in BinaryUtils.WriteToStreamForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertaarea-Host untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
dotnet/runtime#137187 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
ImmutableSortedSet<T>.Builder: enumerating through IEnumerable<T> doesn't throw on modification and can return wrong itemsForse già presa @aw0lid l’ha presa 1 giorno fa. Apertaarea-System.Collections
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
dotnet/runtime#137167 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
DbTransaction.SupportsSavepoints docs say Release/ReleaseAsync are expected to throw, but they are no-ops by designForse già presa @alaricd l’ha presa 5 giorni fa. Apertaarea-System.Transactions untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
dotnet/runtime#137040 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
FileSystemGlobbing: Matcher throws ArgumentOutOfRangeException when the rootDir is the same value as the fileForse già presa @makazeu l’ha presa 5 giorni fa. Apertaarea-Extensions-FileSystem
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
dotnet/runtime#136989 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Configuration binder source generator emits unqualified List<T> when binding arrays without implicit usingsForse già presa @makazeu l’ha presa 5 giorni fa. Apertaarea-Extensions-Configuration bug source-generator
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
dotnet/runtime#136972 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di dotnet/runtime
Issue simili
-
SkillsApertawayfinder:grilling
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
DigiBanks99/lopen#37 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
sebastienros/fluid#1273 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
[Feature]: Add Ukrainian (Українська) as a target language for the Translator (Ollama) engineApertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
KnifeLemon/Filee#1344 ·
I maintainer di solito rispondono entro 1 giorno