Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenXmlValidator not validating boolean values #887

Closed
1 of 2 tasks
igitur opened this issue Feb 21, 2021 · 10 comments · Fixed by #890
Closed
1 of 2 tasks

OpenXmlValidator not validating boolean values #887

igitur opened this issue Feb 21, 2021 · 10 comments · Fixed by #890

Comments

@igitur
Copy link
Contributor

igitur commented Feb 21, 2021

Before submitting an issue, please fill this out

Is this a:

  • Issue with the OpenXml library
  • Question on library usage

If you have answered that this is a question, please ask it on StackOverflow instead of here.
This issue tracker is meant to track product issues while StackOverflow excels at answering questions

---------------- Remove this line and above before posting ----------------

Description

This looks like a regression. Values of type boolean, but with values 0 or 1 in the OpenXML document fail to validate.

Information

  • .NET Target: .NET Core 3.1
  • DocumentFormat.OpenXml Version: 2.12.0

This problem doesn't exist in 2.11.3, hence it looks like a regression between 2.11.3 and 2.12.0.

Repro

var version = typeof(SpreadsheetDocument).Assembly.GetName().Version.ToString();
Console.WriteLine(version);
using var package = SpreadsheetDocument.Open("test.xlsx", isEditable: false);
var validator = new OpenXmlValidator();
var errors = validator.Validate(package);

if (errors.Any())
{
    Console.WriteLine("This file should validate.");
    Console.WriteLine();
    foreach (var e in errors)
    {
        Console.WriteLine($"Part {e.Part.Uri}, Path {e.Path.XPath}: {e.Description}");
    }
}
else
    Console.WriteLine("No validation errors");

Test file: test.xlsx

Observed

OpenXmlValidator.Validate() produces errors.

2.12.0.0
This file should validate.

Part /xl/worksheets/sheet1.xml, Path /x:worksheet[1]/x:sheetData[1]/x:row[5]/x:c[3]: Cell contents have invalid value '0' for type 'Boolean'.
Part /xl/worksheets/sheet1.xml, Path /x:worksheet[1]/x:sheetData[1]/x:row[4]/x:c[3]: Cell contents have invalid value '0' for type 'Boolean'.
Part /xl/worksheets/sheet1.xml, Path /x:worksheet[1]/x:sheetData[1]/x:row[3]/x:c[3]: Cell contents have invalid value '1' for type 'Boolean'.

Expected

OpenXmlValidator.Validate() should not produce errors.

@igitur igitur changed the title OpenXMLValidator not validating boolean values OpenXmlValidator not validating boolean values Feb 21, 2021
@twsouthwick
Copy link
Member

Thanks for the issue! I added some better cell validation but apparently didn't handle this case. I'll get a fix in.

@igitur
Copy link
Contributor Author

igitur commented Feb 26, 2021

@twsouthwick Hope it's OK if I continue this issue. Else I'll open a new one if required.

We have fairly comprehensive test suite in ClosedXML and after upgrading to OpenXML 2.12.2 the problem described above was the cause of the majority of our test failures. Only now, after upgrading to 2.12.3, did I notice there were other, similar validation issues. Sorry, they fell through the cracks previously.

For example, this fails the validation too:

<c r="C12" s="12">
    <x:v>9.999E+307</x:v>
</c>

So far, I can't see any other validation issues.

@twsouthwick twsouthwick reopened this Feb 26, 2021
@twsouthwick
Copy link
Member

Thanks! How about we get a fix for that and we'll iterate until you have a clean test suite?

@igitur
Copy link
Contributor Author

igitur commented Feb 26, 2021

I added a PR at #901

@twsouthwick
Copy link
Member

@igitur Sorry I was on vacation last week and been catching up on stuff. We released a beta of 2.13.0 that has this fix. Can you verify with that build? We can get a 2.12.4 out once we've got all your regressions addressed.

@igitur
Copy link
Contributor Author

igitur commented Mar 12, 2021

Thanks @twsouthwick . I tested against the beta version and all these kinds of parsing issues seem to be resolved, at least as far as our test suite covers.

Just something that I noticed, and it's not really a big issue, but I notice that now all the .xml files in the package have a BOM at the start of the file. Was this intentional? Or maybe it's a side effect of a newer System.IO.Packaging version?

@twsouthwick
Copy link
Member

twsouthwick commented Mar 12, 2021

That would be due to #309. It was intentional and allows it to be open by more editors.

@twsouthwick
Copy link
Member

We plan on releasing 2.13.0 end of the month. Is that OK timeframe or would a patch release be better?

@igitur
Copy link
Contributor Author

igitur commented Mar 13, 2021

Thanks. Yes, that timeframe is all good.

@igitur
Copy link
Contributor Author

igitur commented Mar 13, 2021

I think we can close this issue now. Thanks for the help.

@igitur igitur closed this as completed Mar 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants