@@ -64,27 +64,27 @@ public ZipWorker(Stream fileStream)
6464 using var reader = XmlReader . Create ( workbookRelsEntry . Open ( ) , XmlSettings ) ;
6565 while ( reader . Read ( ) )
6666 {
67- if ( reader . NodeType == XmlNodeType . Element && reader . Name == "Relationship" )
68- {
69- var id = reader . GetAttribute ( "Id" ) ;
70- var type = reader . GetAttribute ( "Type" ) ;
71- var target = reader . GetAttribute ( "Target" ) ;
67+ if ( reader . NodeType != XmlNodeType . Element || reader . Name != "Relationship" )
68+ continue ;
7269
73- switch ( type )
74- {
75- case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" :
76- case "http://purl.oclc.org/ooxml/officeDocument/relationships/worksheet" :
77- _worksheetRels [ id ] = ResolvePath ( basePath , target ) ;
78- break ;
79- case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" :
80- case "http://purl.oclc.org/ooxml/officeDocument/relationships/styles" :
81- _fileStyles = ResolvePath ( basePath , target ) ;
82- break ;
83- case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" :
84- case "http://purl.oclc.org/ooxml/officeDocument/relationships/sharedStrings" :
85- _fileSharedStrings = ResolvePath ( basePath , target ) ;
86- break ;
87- }
70+ var id = reader . GetAttribute ( "Id" ) ;
71+ var type = reader . GetAttribute ( "Type" ) ;
72+ var target = reader . GetAttribute ( "Target" ) ;
73+
74+ switch ( type )
75+ {
76+ case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" :
77+ case "http://purl.oclc.org/ooxml/officeDocument/relationships/worksheet" :
78+ _worksheetRels [ id ] = ResolvePath ( basePath , target ) ;
79+ break ;
80+ case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" :
81+ case "http://purl.oclc.org/ooxml/officeDocument/relationships/styles" :
82+ _fileStyles = ResolvePath ( basePath , target ) ;
83+ break ;
84+ case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" :
85+ case "http://purl.oclc.org/ooxml/officeDocument/relationships/sharedStrings" :
86+ _fileSharedStrings = ResolvePath ( basePath , target ) ;
87+ break ;
8888 }
8989 }
9090
@@ -112,17 +112,17 @@ static string ResolvePath(string? basePath, string path)
112112 using var reader = XmlReader . Create ( entry . Open ( ) , XmlSettings ) ;
113113 while ( reader . Read ( ) )
114114 {
115- if ( reader . NodeType == XmlNodeType . Element && reader . Name == "Relationship" )
115+ if ( reader . NodeType != XmlNodeType . Element || reader . Name != "Relationship" )
116+ continue ;
117+
118+ var type = reader . GetAttribute ( "Type" ) ;
119+ var target = reader . GetAttribute ( "Target" ) ;
120+
121+ switch ( type )
116122 {
117- var type = reader . GetAttribute ( "Type" ) ;
118- var target = reader . GetAttribute ( "Target" ) ;
119-
120- switch ( type )
121- {
122- case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" :
123- case "http://purl.oclc.org/ooxml/officeDocument/relationships/officeDocument" :
124- return target ;
125- }
123+ case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" :
124+ case "http://purl.oclc.org/ooxml/officeDocument/relationships/officeDocument" :
125+ return target ;
126126 }
127127 }
128128
0 commit comments