From df7a32cb8f0aeccb68b72c969d4c3f4454bdc001 Mon Sep 17 00:00:00 2001 From: Antony Liu Date: Wed, 13 Mar 2024 11:29:19 +0800 Subject: [PATCH 1/8] poi: make code more similar between default case and indexed case --- ooxml/POIXMLDocumentPart.cs | 109 ++++++++++++++++++++++++------------ 1 file changed, 73 insertions(+), 36 deletions(-) diff --git a/ooxml/POIXMLDocumentPart.cs b/ooxml/POIXMLDocumentPart.cs index 8521c3587..fe597250d 100644 --- a/ooxml/POIXMLDocumentPart.cs +++ b/ooxml/POIXMLDocumentPart.cs @@ -14,6 +14,7 @@ the License. You may obtain a copy of the License at See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ + namespace NPOI { using NPOI.Util; @@ -22,7 +23,7 @@ namespace NPOI using System.Collections.Generic; using System.IO; using NPOI.OpenXml4Net.Exceptions; -using System.Xml; + using System.Xml; using NPOI.OpenXml4Net.OPC.Internal; using System.Diagnostics; @@ -35,6 +36,7 @@ namespace NPOI * * @author Yegor Kozlov */ + public class POIXMLDocumentPart { private static POILogger logger = POILogFactory.GetLogger(typeof(POIXMLDocumentPart)); @@ -50,11 +52,12 @@ public class POIXMLDocumentPart * The child document parts may only belong to one parent, but it's often referenced by other * parents too, having varying {@link PackageRelationship#getId() relationship ids} pointing to it. */ + public class RelationPart { private PackageRelationship relationship; private POIXMLDocumentPart documentPart; - + internal RelationPart(PackageRelationship relationship, POIXMLDocumentPart documentPart) { this.relationship = relationship; @@ -64,6 +67,7 @@ internal RelationPart(PackageRelationship relationship, POIXMLDocumentPart docum /** * @return the cached relationship, which uniquely identifies this child document part within the parent */ + public PackageRelationship Relationship { get @@ -75,7 +79,8 @@ public PackageRelationship Relationship /** * @return the child document part */ - public T GetDocumentPart() where T: POIXMLDocumentPart + + public T GetDocumentPart() where T : POIXMLDocumentPart { return (T)documentPart; } @@ -95,19 +100,19 @@ public POIXMLDocumentPart DocumentPart */ private int relationCounter = 0; - int IncrementRelationCounter() + private int IncrementRelationCounter() { relationCounter++; return relationCounter; } - int DecrementRelationCounter() + private int DecrementRelationCounter() { relationCounter--; return relationCounter; } - int GetRelationCounter() + private int GetRelationCounter() { return relationCounter; } @@ -115,6 +120,7 @@ int GetRelationCounter() /** * Construct POIXMLDocumentPart representing a "core document" namespace part. */ + public POIXMLDocumentPart(OPCPackage pkg) : this(pkg, PackageRelationshipTypes.CORE_DOCUMENT) { @@ -123,6 +129,7 @@ public POIXMLDocumentPart(OPCPackage pkg) /** * Construct POIXMLDocumentPart representing a custom "core document" package part. */ + public POIXMLDocumentPart(OPCPackage pkg, String coreDocumentRel) : this(GetPartFromOPCPackage(pkg, coreDocumentRel)) { @@ -134,9 +141,11 @@ public POIXMLDocumentPart(OPCPackage pkg, String coreDocumentRel) * * @see #CreateRelationship(POIXMLRelation, POIXMLFactory, int, bool) */ + public POIXMLDocumentPart() { } + /** * Creates an POIXMLDocumentPart representing the given package part and relationship. * Called by {@link #read(POIXMLFactory, java.util.Map)} when reading in an existing file. @@ -146,11 +155,12 @@ public POIXMLDocumentPart() * * @since POI 3.14-Beta1 */ + public POIXMLDocumentPart(PackagePart part) : this(null, part) { - } + /** * Creates an POIXMLDocumentPart representing the given package part, relationship and parent * Called by {@link #read(POIXMLFactory, java.util.Map)} when reading in an existing file. @@ -161,11 +171,13 @@ public POIXMLDocumentPart(PackagePart part) * * @since POI 3.14-Beta1 */ + public POIXMLDocumentPart(POIXMLDocumentPart parent, PackagePart part) { this.packagePart = part; this.parent = parent; } + /** * Creates an POIXMLDocumentPart representing the given namespace part and relationship. * Called by {@link #read(POIXMLFactory, java.util.Map)} when Reading in an exisiting file. @@ -174,9 +186,10 @@ public POIXMLDocumentPart(POIXMLDocumentPart parent, PackagePart part) * @param rel - the relationship of the given namespace part * @see #read(POIXMLFactory, java.util.Map) */ - [Obsolete("deprecated in POI 3.14, scheduled for removal in POI 3.16")] + + [Obsolete("deprecated in POI 3.14, scheduled for removal in POI 3.16")] public POIXMLDocumentPart(PackagePart part, PackageRelationship rel) - : this(null, part) + : this(null, part) { } @@ -189,9 +202,10 @@ public POIXMLDocumentPart(PackagePart part, PackageRelationship rel) * @param rel - the relationship of the given namespace part * @see #read(POIXMLFactory, java.util.Map) */ - [Obsolete("deprecated in POI 3.14, scheduled for removal in POI 3.16")] + + [Obsolete("deprecated in POI 3.14, scheduled for removal in POI 3.16")] public POIXMLDocumentPart(POIXMLDocumentPart parent, PackagePart part, PackageRelationship rel) - : this(null, part) + : this(null, part) { } @@ -200,6 +214,7 @@ public POIXMLDocumentPart(POIXMLDocumentPart parent, PackagePart part, PackageRe * re-base the XML Document onto the core child of the * current core document */ + protected void Rebase(OPCPackage pkg) { PackageRelationshipCollection cores = @@ -213,15 +228,19 @@ protected void Rebase(OPCPackage pkg) } packagePart = packagePart.GetRelatedPart(cores.GetRelationship(0)); } - static XmlNamespaceManager nsm = null; + + private static XmlNamespaceManager nsm = null; + public static XmlNamespaceManager NamespaceManager { - get { + get + { if (nsm == null) nsm = CreateDefaultNSM(); return nsm; } } + internal static XmlNamespaceManager CreateDefaultNSM() { // Create a NamespaceManager to handle the default namespace, @@ -235,14 +254,14 @@ internal static XmlNamespaceManager CreateDefaultNSM() ns.AddNamespace("r", PackageNamespaces.SCHEMA_RELATIONSHIPS); ns.AddNamespace("c", PackageNamespaces.SCHEMA_CHART); ns.AddNamespace("vt", PackageNamespaces.SCHEMA_VT); - ns.AddNamespace("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"); + ns.AddNamespace("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"); ns.AddNamespace("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"); ns.AddNamespace("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"); ns.AddNamespace("ve", "http://schemas.openxmlformats.org/markup-compatibility/2006"); ns.AddNamespace("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); ns.AddNamespace("o", "urn:schemas-microsoft-com:office:office"); ns.AddNamespace("v", "urn:schemas-microsoft-com:vml"); - ns.AddNamespace("wne","http://schemas.microsoft.com/office/word/2006/wordml"); + ns.AddNamespace("wne", "http://schemas.microsoft.com/office/word/2006/wordml"); // extended properties (app.xml) ns.AddNamespace("xp", PackageRelationshipTypes.EXTENDED_PROPERTIES); // custom properties @@ -259,11 +278,13 @@ internal static XmlNamespaceManager CreateDefaultNSM() ns.AddNamespace("w14", "http://schemas.microsoft.com/office/word/2010/wordml"); return ns; } + /** * Provides access to the underlying PackagePart * * @return the underlying PackagePart */ + public PackagePart GetPackagePart() { return packagePart; @@ -281,7 +302,8 @@ public static XmlDocument ConvertStreamToXml(Stream xmlStream) * * @return the PackageRelationship that identifies this POIXMLDocumentPart */ - [Obsolete("deprecated in POI 3.14, scheduled for removal in POI 3.16")] + + [Obsolete("deprecated in POI 3.14, scheduled for removal in POI 3.16")] public PackageRelationship GetPackageRelationship() { if (this.parent != null) @@ -314,6 +336,7 @@ public PackageRelationship GetPackageRelationship() * * @return child relations */ + public IList GetRelations() { List l = new List(); @@ -329,6 +352,7 @@ public IList GetRelations() * * @return child relations */ + public IList RelationParts { get @@ -349,14 +373,14 @@ public IList RelationParts * The relation id to look for * @return the target part of the relation, or null, if none exists */ + public POIXMLDocumentPart GetRelationById(String id) { - if (string.IsNullOrEmpty(id)|| !relations.ContainsKey(id)) + if (string.IsNullOrEmpty(id) || !relations.ContainsKey(id)) return null; RelationPart rp = relations[id]; return (rp == null) ? null : rp.DocumentPart; - } /** @@ -371,6 +395,7 @@ public POIXMLDocumentPart GetRelationById(String id) * @return The value of the {@link PackageRelationship#GetId()} or null, if * parts are not related. */ + public String GetRelationId(POIXMLDocumentPart part) { foreach (RelationPart rp in relations.Values) @@ -394,6 +419,7 @@ public void AddRelation(String id, POIXMLDocumentPart part) PackageRelationship pr = part.GetPackagePart().GetRelationship(id); AddRelation(pr, part); } + /// /// Add a new child POIXMLDocumentPart /// @@ -403,7 +429,7 @@ public void AddRelation(String id, POIXMLDocumentPart part) /// public RelationPart AddRelation(String relId, POIXMLRelation relationshipType, POIXMLDocumentPart part) { - PackageRelationship pr = this.packagePart.FindExistingRelation(part.GetPackagePart()); + PackageRelationship pr = this.packagePart.FindExistingRelation(part.GetPackagePart()); if (pr == null) { PackagePartName ppn = part.GetPackagePart().PartName; @@ -413,6 +439,7 @@ public RelationPart AddRelation(String relId, POIXMLRelation relationshipType, P AddRelation(pr, part); return new RelationPart(pr, part); } + /// /// Add a new child POIXMLDocumentPart /// @@ -425,13 +452,13 @@ private void AddRelation(PackageRelationship pr, POIXMLDocumentPart part) else relations.Add(pr.Id, new RelationPart(pr, part)); part.IncrementRelationCounter(); - } /** * Remove the relation to the specified part in this namespace and remove the * part, if it is no longer needed. */ + protected internal void RemoveRelation(POIXMLDocumentPart part) { RemoveRelation(part, true); @@ -447,6 +474,7 @@ protected internal void RemoveRelation(POIXMLDocumentPart part) * true, if the part shall be Removed from the namespace if not * needed any longer. */ + protected internal bool RemoveRelation(POIXMLDocumentPart part, bool RemoveUnusedParts) { String id = GetRelationId(part); @@ -486,6 +514,7 @@ protected internal bool RemoveRelation(POIXMLDocumentPart part, bool RemoveUnuse * * @return the parent POIXMLDocumentPart or null for the root element. */ + public POIXMLDocumentPart GetParent() { return parent; @@ -514,9 +543,9 @@ public override String ToString() * * */ + protected internal virtual void Commit() { - } /** @@ -525,6 +554,7 @@ protected internal virtual void Commit() * * @param alreadySaved context set Containing already visited nodes */ + protected internal void OnSave(List alreadySaved) { // this usually clears out previous content in the part... @@ -541,6 +571,7 @@ protected internal void OnSave(List alreadySaved) } } } + /** * Ensure that a memory based package part does not have lingering data from previous * commit() calls. @@ -548,6 +579,7 @@ protected internal void OnSave(List alreadySaved) * Note: This is overwritten for some objects, as *PictureData seem to store the actual content * in the part directly without keeping a copy like all others therefore we need to handle them differently. */ + protected internal virtual void PrepareForCommit() { PackagePart part = this.GetPackagePart(); @@ -556,6 +588,7 @@ protected internal virtual void PrepareForCommit() part.Clear(); } } + /** * Create a new child POIXMLDocumentPart * @@ -563,6 +596,7 @@ protected internal virtual void PrepareForCommit() * @param factory the factory that will create an instance of the requested relation * @return the Created child POIXMLDocumentPart */ + public POIXMLDocumentPart CreateRelationship(POIXMLRelation descriptor, POIXMLFactory factory) { return CreateRelationship(descriptor, factory, -1, false).DocumentPart; @@ -589,16 +623,18 @@ public POIXMLDocumentPart CreateRelationship(POIXMLRelation descriptor, POIXMLFa * @param minIdx The minimum free index to assign, use -1 for any * @return The next free part number, or -1 if none available */ + protected internal int GetNextPartNumber(POIXMLRelation descriptor, int minIdx) { OPCPackage pkg = packagePart.Package; try { - if (descriptor.DefaultFileName.Equals(descriptor.GetFileName(9999))) + string name = descriptor.DefaultFileName; + if (name.Equals(descriptor.GetFileName(9999))) { // Non-index based, check if default is free - PackagePartName ppName = PackagingUriHelper.CreatePartName(descriptor.DefaultFileName); + PackagePartName ppName = PackagingUriHelper.CreatePartName(name); if (pkg.ContainPart(ppName)) { // Default name already taken, not index based, nothing free @@ -616,8 +652,9 @@ protected internal int GetNextPartNumber(POIXMLRelation descriptor, int minIdx) if (minIdx < 0) idx = 1; while (idx < 1000) { - String name = descriptor.GetFileName(idx); - if (!pkg.ContainPart(PackagingUriHelper.CreatePartName(name))) + name = descriptor.GetFileName(idx); + PackagePartName ppName = PackagingUriHelper.CreatePartName(name); + if (!pkg.ContainPart(ppName)) { return idx; } @@ -641,6 +678,7 @@ protected internal int GetNextPartNumber(POIXMLRelation descriptor, int minIdx) * @param noRelation if true, then no relationship is Added. * @return the Created child POIXMLDocumentPart */ + protected RelationPart CreateRelationship(POIXMLRelation descriptor, POIXMLFactory factory, int idx, bool noRelation) { try @@ -688,6 +726,7 @@ public TValue PutDictionary(Dictionary dict, TKey ke dict.Add(key, value); return oldValue; } + public TValue GetDictionary(Dictionary dict, TKey key) { if (dict.ContainsKey(key)) @@ -696,6 +735,7 @@ public TValue GetDictionary(Dictionary dict, TKey ke } return default(TValue); } + /** * Iterate through the underlying PackagePart and create child POIXMLFactory instances * using the specified factory @@ -703,6 +743,7 @@ public TValue GetDictionary(Dictionary dict, TKey ke * @param factory the factory object that Creates POIXMLFactory instances * @param context context map Containing already visited noted keyed by tarGetURI */ + protected void Read(POIXMLFactory factory, Dictionary context) { PackagePart pp = GetPackagePart(); @@ -772,6 +813,7 @@ protected void Read(POIXMLFactory factory, Dictionary Date: Wed, 13 Mar 2024 11:35:36 +0800 Subject: [PATCH 2/8] poi: disabled unit tests are now passing for bug 48703 --- testcases/main/HSSF/UserModel/TestBugs.cs | 13 +++++++------ testcases/ooxml/XSSF/UserModel/TestXSSFBugs.cs | 2 -- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/testcases/main/HSSF/UserModel/TestBugs.cs b/testcases/main/HSSF/UserModel/TestBugs.cs index 1836eed49..7e07fe21b 100644 --- a/testcases/main/HSSF/UserModel/TestBugs.cs +++ b/testcases/main/HSSF/UserModel/TestBugs.cs @@ -2749,12 +2749,13 @@ public void Test51535() Assert.IsTrue(text.Contains("Bottom Right Cell")); } } + /** - * Sum across multiple workbooks - * eg =SUM($Sheet2.A1:$Sheet3.A1) - * DISABLED - We currently get the formula wrong, and mis-evaluate - */ - public void DISABLEDtest48703() + * Sum across multiple workbooks + * eg =SUM($Sheet2.A1:$Sheet3.A1) + */ + [Test] + public void Test48703() { HSSFWorkbook wb = OpenSample("48703.xls"); Assert.AreEqual(3, wb.NumberOfSheets); @@ -2764,7 +2765,7 @@ public void DISABLEDtest48703() IRow r = sheet.GetRow(0); ICell c = r.GetCell(0); - Assert.AreEqual("SUM(Sheet2!A1:Sheet3!A1)", c.CellFormula); + Assert.AreEqual("SUM(Sheet2:Sheet3!A1)", c.CellFormula); Assert.AreEqual(4.0, c.NumericCellValue); // Check the evaluated result diff --git a/testcases/ooxml/XSSF/UserModel/TestXSSFBugs.cs b/testcases/ooxml/XSSF/UserModel/TestXSSFBugs.cs index 204b750e9..9934980b9 100644 --- a/testcases/ooxml/XSSF/UserModel/TestXSSFBugs.cs +++ b/testcases/ooxml/XSSF/UserModel/TestXSSFBugs.cs @@ -1495,9 +1495,7 @@ public void Test51963() /** * Sum across multiple workbooks * eg =SUM($Sheet1.C1:$Sheet4.C1) - * DISABLED As we can't currently Evaluate these */ - [Ignore("by poi")] [Test] public void Test48703() { From f00694d8ea5c3a16bca7f684a3949a759471df3c Mon Sep 17 00:00:00 2001 From: Antony Liu Date: Wed, 13 Mar 2024 13:04:46 +0800 Subject: [PATCH 3/8] poi: bug 60255: use actual number of package parts rather than hard-coding an upper-bound --- ooxml/POIXMLDocumentPart.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ooxml/POIXMLDocumentPart.cs b/ooxml/POIXMLDocumentPart.cs index fe597250d..17970d33a 100644 --- a/ooxml/POIXMLDocumentPart.cs +++ b/ooxml/POIXMLDocumentPart.cs @@ -650,7 +650,8 @@ protected internal int GetNextPartNumber(POIXMLRelation descriptor, int minIdx) // Default to searching from 1, unless they asked for 0+ int idx = minIdx; if (minIdx < 0) idx = 1; - while (idx < 1000) + int maxIdx = minIdx + pkg.GetParts().Count; + while (idx < maxIdx) { name = descriptor.GetFileName(idx); PackagePartName ppName = PackagingUriHelper.CreatePartName(name); From 3c549f68488e5abdd1591f31700f9afebaba0ff7 Mon Sep 17 00:00:00 2001 From: Antony Liu Date: Wed, 13 Mar 2024 13:10:16 +0800 Subject: [PATCH 4/8] poi: reenable unit test for bug 58648 that passes now --- testcases/main/SS/UserModel/BaseTestBugzillaIssues.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/testcases/main/SS/UserModel/BaseTestBugzillaIssues.cs b/testcases/main/SS/UserModel/BaseTestBugzillaIssues.cs index 99f7c2984..b67028fb1 100644 --- a/testcases/main/SS/UserModel/BaseTestBugzillaIssues.cs +++ b/testcases/main/SS/UserModel/BaseTestBugzillaIssues.cs @@ -1380,9 +1380,11 @@ public void Test50319() wb.Close(); } - [Ignore("by poi")] + // Bug 58648: FormulaParser throws exception in parseSimpleFactor() when getCellFormula() + // is called on a cell and the formula contains spaces between closing parentheses ") )" + // https://bz.apache.org/bugzilla/show_bug.cgi?id=58648 [Test] - public void test58648() + public void Test58648() { IWorkbook wb = _testDataProvider.CreateWorkbook(); ICell cell = wb.CreateSheet().CreateRow(0).CreateCell(0); From 262ce9eb3ce73a10df2382bd3cfe8cb25aefb5fa Mon Sep 17 00:00:00 2001 From: Antony Liu Date: Wed, 13 Mar 2024 13:21:09 +0800 Subject: [PATCH 5/8] poi: add StringUtil.count, inspired by Apache Commons Lang StringUtils#countMatches and Python's str.count(substr) --- main/Util/StringUtil.cs | 23 +++++++++++++++++++ testcases/main/Util/TestStringUtil.cs | 20 ++++++++++++++++ .../XWPF/Extractor/TestXWPFWordExtractor.cs | 14 ++++------- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/main/Util/StringUtil.cs b/main/Util/StringUtil.cs index 4bb30c4a8..bf882fed9 100644 --- a/main/Util/StringUtil.cs +++ b/main/Util/StringUtil.cs @@ -854,5 +854,28 @@ public static String Join(String separator, params object[] array) { return Join(array, separator); } + + /** + * Count number of occurrences of needle in haystack + * Has same signature as org.apache.commons.lang3.StringUtils#countMatches + * + * @param haystack the CharSequence to check, may be null + * @param needle the character to count the quantity of + * @return the number of occurrences, 0 if the CharSequence is null + */ + public static int CountMatches(string haystack, char needle) + { + if (haystack == null) return 0; + int count = 0; + int length = haystack.Length; + for (int i = 0; i < length; i++) + { + if (haystack[i] == needle) + { + count++; + } + } + return count; + } } } diff --git a/testcases/main/Util/TestStringUtil.cs b/testcases/main/Util/TestStringUtil.cs index 1506b6e34..053db9168 100644 --- a/testcases/main/Util/TestStringUtil.cs +++ b/testcases/main/Util/TestStringUtil.cs @@ -253,6 +253,26 @@ public void Join() Assert.AreEqual("abc|def|ghi", StringUtil.Join("|", "abc", "def", "ghi")); Assert.AreEqual("5|8.5|True|string", StringUtil.Join("|", 5, 8.5, true, "string")); //assumes Locale prints number decimal point as a period rather than a comma } + + [Test] + public void Count() + { + String test = "Apache POI project\n\u00a9 Copyright 2016"; + // supports search in null or empty string + Assert.AreEqual(0, StringUtil.CountMatches(null, 'A'), "null"); + Assert.AreEqual(0, StringUtil.CountMatches("", 'A'), "empty string"); + + Assert.AreEqual(2, StringUtil.CountMatches(test, 'e'), "normal"); + Assert.AreEqual(1, StringUtil.CountMatches(test, 'a'), "normal, should not find a in escaped copyright"); + + // search for non-printable characters + Assert.AreEqual(0, StringUtil.CountMatches(test, '\0'), "null character"); + Assert.AreEqual(0, StringUtil.CountMatches(test, '\r'), "CR"); + Assert.AreEqual(1, StringUtil.CountMatches(test, '\n'), "LF"); + + // search for unicode characters + Assert.AreEqual(1, StringUtil.CountMatches(test, '\u00a9'), "Unicode"); + } } } diff --git a/testcases/ooxml/XWPF/Extractor/TestXWPFWordExtractor.cs b/testcases/ooxml/XWPF/Extractor/TestXWPFWordExtractor.cs index 20a7bd8d9..56adc3a90 100644 --- a/testcases/ooxml/XWPF/Extractor/TestXWPFWordExtractor.cs +++ b/testcases/ooxml/XWPF/Extractor/TestXWPFWordExtractor.cs @@ -17,6 +17,7 @@ limitations under the License. namespace TestCases.XWPF.Extractor { + using NPOI.Util; using NPOI.XWPF.Extractor; using NPOI.XWPF.UserModel; using NUnit.Framework; @@ -53,16 +54,9 @@ public void TestGetSimpleText() )); // Check number of paragraphs - int ps = 0; - char[] t = text.ToCharArray(); - for (int i = 0; i < t.Length; i++) - { - if (t[i] == '\n') - { - ps++; - } - } - Assert.AreEqual(3, ps); + // Check number of paragraphs by counting number of newlines + int numberOfParagraphs = StringUtil.CountMatches(text, '\n'); + Assert.AreEqual(3, numberOfParagraphs); } /** From 3ef3120fba97006fe39c037fed8b8c12551c0367 Mon Sep 17 00:00:00 2001 From: Antony Liu Date: Wed, 13 Mar 2024 13:41:31 +0800 Subject: [PATCH 6/8] poi: BUG-60284 -- throw EncryptedDocumentException for password protected OldExcel files --- main/HSSF/Extractor/OldExcelExtractor.cs | 4 +++ .../HSSF/Extractor/TestOldExcelExtractor.cs | 31 ++++++++++++++---- testcases/test-data/spreadsheet/60284.xls | Bin 0 -> 40448 bytes 3 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 testcases/test-data/spreadsheet/60284.xls diff --git a/main/HSSF/Extractor/OldExcelExtractor.cs b/main/HSSF/Extractor/OldExcelExtractor.cs index 62c02c491..e42e83b58 100644 --- a/main/HSSF/Extractor/OldExcelExtractor.cs +++ b/main/HSSF/Extractor/OldExcelExtractor.cs @@ -39,6 +39,7 @@ namespace NPOI.HSSF.Extractor */ public class OldExcelExtractor { + private const int FILE_PASS_RECORD_SID = 0x2f; private RecordInputStream ris; // sometimes we hold the stream here and thus need to ensure it is closed at some point @@ -247,6 +248,9 @@ public String Text switch (sid) { + case FILE_PASS_RECORD_SID: + throw new EncryptedDocumentException("Encryption not supported for Old Excel files"); + // Biff 5+ only, no sheet names in older formats case OldSheetRecord.sid: OldSheetRecord shr = new OldSheetRecord(ris); diff --git a/testcases/main/HSSF/Extractor/TestOldExcelExtractor.cs b/testcases/main/HSSF/Extractor/TestOldExcelExtractor.cs index 43df6a9c1..271dbfc50 100644 --- a/testcases/main/HSSF/Extractor/TestOldExcelExtractor.cs +++ b/testcases/main/HSSF/Extractor/TestOldExcelExtractor.cs @@ -17,16 +17,16 @@ limitations under the License. namespace TestCases.HSSF.Extractor { - using System; - using NPOI.HSSF; - using TestCases; - using NUnit.Framework; - using System.IO; - using TestCases.HSSF; + using NPOI; using NPOI.HSSF.Extractor; using NPOI.POIFS.FileSystem; using NPOI.Util; + using NUnit.Framework; + using System; + using System.IO; using System.Text; + using TestCases; + using TestCases.HSSF; /** * Unit tests for the Excel 5/95 and Excel 4 (and older) text @@ -386,7 +386,24 @@ public void TestMain() Console.SetOut(save); } } - + [Test] + public void TestEncryptionException() + { + //test file derives from Common Crawl + FileInfo file = HSSFTestDataSamples.GetSampleFile("60284.xls"); + OldExcelExtractor ex = new OldExcelExtractor(file); + Assert.AreEqual(5, ex.BiffVersion); + Assert.AreEqual(5, ex.FileType); + try + { + var x = ex.Text; + Assert.Fail(); + } + catch (EncryptedDocumentException) + { + Assert.IsTrue(true, "correct exception thrown"); + } + } } } diff --git a/testcases/test-data/spreadsheet/60284.xls b/testcases/test-data/spreadsheet/60284.xls new file mode 100644 index 0000000000000000000000000000000000000000..7e0f9fb8332abfbffa58a554cc650c29786cb0ab GIT binary patch literal 40448 zcmeFa30PFe(l>s9GpL|wj0>V3kxfO#4VP$wtnPwIaE-xnSacW|+@mHM1a;gcWHOE; z0R;hfv$$PN5JAOVW4y+wAu=Q47GjKg4I2G^)#uCtPTqU-e(&@A|KIm~_%xjE)2F(s zx~jUXs?YJl`PXi2`qHC44G^r4x!jN@tWVC|ywkP`aUX zN9lpm6QvhQAWCnPJ}7-r`k}mm(jR32%9|)}p#-4}L3sPF$RKkslU_%{o45y7ePcLp~P6#nNwEg&&wUO3{hCiUqz#}%{RjFsXQ ze#_sVDLd_d(IFhy!6Y>J31#D}#L9o;w+rX!K;x6V(%=6C1YtO6q1ba0HwHL_aFe)E z+&f$p<~jm)E&4wJ!}@q|4h{~uBE2CUviFlZF!yZ3^QRole{K83aZ2#~zyDKTqMvm4 zKc$~^Z4W6qej3z=mdj+^q_$`4b%O;M|Fw&u0_{gQM^4Kh##J$j5oIDbjeF9?<<|aH zzXzlyXu}7rZV`KkJHIRYmPeICf=6;@TvlQRm!9%JSq}vkX|dm9^ekMB=3C(RLQ_jv zr_EK9_uucC(h|n%&Xc>kQ1_O&!dkf`F6pyl ze485fBzn?7UP7)rtQ5w1Jc!0+fFs6@*lRM}QI=iWJpN5fcOT7g+z)k!u|uzti5OnQ z_Th+8JH6{*drXnz4vUB}wp+1%P<(aRrolhGRUu+e*!pNr8)6A0km}=Qre0XNz00U> z-{njZxlzKfnyRaChk*qSPJ=}faQD|^mv)S+A6sYiN^x|6J8I>@i*uJfFLtcMt)rT| zG&&F}>TIURu;PoI!};+#rAQx9ZIXovx2YotI&CGWyXVzAC%eSAW%w!gvHtn0XGD1$ zrEcR@X)*=V)-IzKU-A3-OBI`3p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&CG_DA-! zjVIC+SqEpE@n%}b6Z;OX)A#Ra^hI2 zY^~BD?Yhb&xvC~Ln0!3 z^$ds_5$ZigIdk^pB+t;vGnKKPgHmRAhD@85q>PTl1 zM!gd?_??iEo`Z&th(4e7V5fi09Bj1gBqi;a?h!Nf+mDo7V zOi7sK8I_QrjE(o~7tq}^N|6{JJIix~QZZxljCmq9Y>DB{ye+_Sua?9=^-FbHUmelhBDctbxnPEB zFBqZyQ#rM^z;*N4bmfUF#cOoc5zk<`{*kV`j}H) zY80-HAEv7b?0(U3x|ZYma~WN!ag|a*SF_mt2mh;mt9Okeh~je|fh$s6kwygBLJ*>y zC>CdB$Z^3!lEpm~Y-Gqz%yM%(>+YW1fyFgxf{j`zC@7*J3gQPytPGZcLkPq~D+>#; z60r$_>+d%k;t`Yl0ph^hee-7aeayUhyYF$=CEkP7FF%RRgSz~j*mcm(7gra*Lf3ns zJ{%?WF|bD^Vz2D;@2ysEfv;L@3D}y&mO1Wl9X{f0AS8-krJs@EMI}6??UVT(F;vt{gm~ae#9l8_(}C0?vpvz# zXTd`y0_!*xsW=a09X)A6$n=^)G_GaXwBwCfhDl@+B?jWNsI^nFhf*7Q9NWn2P%W_e z-EnL(5B({afS==FsRo;aSTNYnvXL$QEE`1>$ud?Qn3Cj;5fBrw&4Ou^8x(Gf z+ecbgM&9K3$@~4`cT0sL=1|w2+HUsmS?RCbsq8D?xC#3YuRo>z-vHE&JgWfKp~e8T zm-bUn4WPYT2io5U4BERF{fR)Qu?g`~ubEb=nvR=xozp2;v@I`8*}U%u(;@UJ*9{`+ z+g^hROI= Date: Wed, 13 Mar 2024 13:57:41 +0800 Subject: [PATCH 7/8] poi: Add some missing close() calls --- testcases/main/HSSF/Extractor/TestOldExcelExtractor.cs | 1 + testcases/main/POIFS/Macros/TestVBAMacroReader.cs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/testcases/main/HSSF/Extractor/TestOldExcelExtractor.cs b/testcases/main/HSSF/Extractor/TestOldExcelExtractor.cs index 271dbfc50..2c023846c 100644 --- a/testcases/main/HSSF/Extractor/TestOldExcelExtractor.cs +++ b/testcases/main/HSSF/Extractor/TestOldExcelExtractor.cs @@ -403,6 +403,7 @@ public void TestEncryptionException() { Assert.IsTrue(true, "correct exception thrown"); } + ex.Close(); } } diff --git a/testcases/main/POIFS/Macros/TestVBAMacroReader.cs b/testcases/main/POIFS/Macros/TestVBAMacroReader.cs index 7012fa34f..f41c8a11d 100644 --- a/testcases/main/POIFS/Macros/TestVBAMacroReader.cs +++ b/testcases/main/POIFS/Macros/TestVBAMacroReader.cs @@ -317,6 +317,7 @@ public void Bug59830() Dictionary macros = r.ReadMacros(); Assert.IsNotNull(macros["Module20"]); StringAssert.Contains("here start of superscripting", macros["Module20"]); + r.Close(); } // This test is written as expected-to-fail and should be rewritten @@ -329,6 +330,7 @@ public void Bug59858() Dictionary macros = r.ReadMacros(); Assert.IsNotNull(macros["Sheet4"]); StringAssert.Contains("intentional constituent", macros["Sheet4"]); + r.Close(); } // This test is written as expected-to-fail and should be rewritten @@ -341,6 +343,7 @@ public void Bug60158() Dictionary macros = r.ReadMacros(); Assert.IsNotNull(macros["NewMacros"]); StringAssert.Contains("' dirty", macros["NewMacros"]); + r.Close(); } [Test] @@ -352,6 +355,7 @@ public void Bug60273() Dictionary macros = r.ReadMacros(); Assert.IsNotNull(macros["Module1"]); StringAssert.Contains("9/8/2004", macros["Module1"]); + r.Close(); } } } \ No newline at end of file From cc1de9aa119f8e20d53d7e22acd565b22db56ea0 Mon Sep 17 00:00:00 2001 From: Antony Liu Date: Wed, 13 Mar 2024 14:06:33 +0800 Subject: [PATCH 8/8] poi: bug 60288: remove defensive copy for internal relationships. Patch from Tim Helmstedt. --- openxml4Net/OPC/OPCPackage.cs | 2 +- openxml4Net/OPC/PackagePart.cs | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/openxml4Net/OPC/OPCPackage.cs b/openxml4Net/OPC/OPCPackage.cs index 2704f5305..327fb58e0 100644 --- a/openxml4Net/OPC/OPCPackage.cs +++ b/openxml4Net/OPC/OPCPackage.cs @@ -1548,7 +1548,7 @@ public bool HasRelationships */ public bool IsRelationshipExists(PackageRelationship rel) { - foreach (PackageRelationship r in this.Relationships) + foreach (PackageRelationship r in relationships) { if (r == rel) return true; diff --git a/openxml4Net/OPC/PackagePart.cs b/openxml4Net/OPC/PackagePart.cs index 75b0463ba..9941ea20d 100644 --- a/openxml4Net/OPC/PackagePart.cs +++ b/openxml4Net/OPC/PackagePart.cs @@ -473,17 +473,10 @@ public bool HasRelationships */ public bool IsRelationshipExists(PackageRelationship rel) { - try + foreach (PackageRelationship r in _relationships) { - foreach (PackageRelationship r in this.Relationships) - { - if (r == rel) - return true; - } - } - catch (InvalidFormatException) - { - + if (r == rel) + return true; } return false; }