Skip to content

Commit 13d720b

Browse files
committed
fix(XMLPatch): validate root element of diff XML before processing, i.e. skipping non-diff XML
1 parent 1ea01bd commit 13d720b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

XMLPatch/Program.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,11 @@ private static void ProcessSingleFile(
278278
}
279279

280280
XElement diffRoot = diffDoc.Root ?? throw new InvalidOperationException("diffDoc.Root is null");
281+
if (diffRoot.Name.LocalName != "diff")
282+
{
283+
Logger.Error($"Root element of diff XML is not 'diff'. Found: '{diffRoot.Name}'.");
284+
return;
285+
}
281286

282287
XElement originalRoot = originalDoc.Root ?? throw new InvalidOperationException("originalDoc.Root is null");
283288

0 commit comments

Comments
 (0)