-
Notifications
You must be signed in to change notification settings - Fork 573
add error for encrypted files #1969
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
Changes from 1 commit
4c53d42
17ee5b6
f697d4e
f8fdcaa
6cc3591
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| using System.IO.Packaging; | ||
| using System.Linq; | ||
| using Xunit; | ||
| using static DocumentFormat.OpenXml.Tests.TestAssets; | ||
|
Check warning on line 13 in test/DocumentFormat.OpenXml.Framework.Tests/Features/StreamPackageFeatureTests.cs
|
||
|
|
||
| namespace DocumentFormat.OpenXml.Features.Tests; | ||
|
|
||
|
|
@@ -431,6 +432,18 @@ | |
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ThrowsForEncryptedOfficeFile() | ||
| { | ||
| using (Stream stream = GetStream(TestFiles.Encrypted_pptx, false)) | ||
| { | ||
| // Act & Assert | ||
| var ex = Assert.Throws<OpenXmlPackageException>(() => new StreamPackageFeature(stream, PackageOpenMode.Read, isOwned: true)); | ||
| Assert.Equal(ExceptionMessages.EncryptedPackageNotSupported, ex.Message); | ||
| } | ||
|
|
||
| } | ||
|
Check warning on line 445 in test/DocumentFormat.OpenXml.Framework.Tests/Features/StreamPackageFeatureTests.cs
|
||
|
|
||
| private static readonly PartInfo Part1 = new(new("/part1", UriKind.Relative), "type1/content"); | ||
| private static readonly PartInfo Part2 = new(new("/part2", UriKind.Relative), "type2/content"); | ||
| private static readonly PartInfo PartRels = new(new("/_rels/.rels", UriKind.Relative), "application/vnd.openxmlformats-package.relationships+xml"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a big deal and may make readability worse, but on some platforms it may prevent an allocation (that is probably not a big deal at all)