Skip to content

Commit 4861f13

Browse files
committed
move file extension check to IsEmptyPartMethod
1 parent e911447 commit 4861f13

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/DocumentFormat.OpenXml.Framework/Packaging/OpenXmlPart.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,11 @@ internal virtual bool IsInVersion(FileFormatVersions version)
450450

451451
internal override bool IsEmptyPart()
452452
{
453+
if (!Uri.ToString().EndsWith(".xml", System.StringComparison.InvariantCultureIgnoreCase))
454+
{
455+
return false;
456+
}
457+
453458
using (Stream stream = GetStream())
454459
{
455460
return stream.Length == 0;

src/DocumentFormat.OpenXml.Framework/Validation/DocumentValidator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private void ValidatePart(OpenXmlPart part, ValidationContext context)
107107
{
108108
Validate(context);
109109
}
110-
else if (part.Uri.ToString().EndsWith(".xml", System.StringComparison.InvariantCultureIgnoreCase) && part.IsEmptyPart())
110+
else if (part.IsEmptyPart())
111111
{
112112
context.AddError(new ValidationErrorInfo
113113
{

0 commit comments

Comments
 (0)