Commit 743ad7f494f202a40bcee5136e38ab8627a685ba
1 parent
e44b04a2
ftguess: Avoid error for unknown OpenXML types
Return False if OpenXML type has no known main relationship part. Otherwise recognize() will raise an error a few lines later at splitext(). This should solve issue #711 (author had suggested exactly this)
Showing
1 changed file
with
7 additions
and
0 deletions
oletools/ftguess.py
| @@ -424,6 +424,13 @@ class FType_Generic_OpenXML(FType_Base): | @@ -424,6 +424,13 @@ class FType_Generic_OpenXML(FType_Base): | ||
| 424 | # else: | 424 | # else: |
| 425 | # # TODO: log error, raise anomaly (or maybe it's the case for XPS?) | 425 | # # TODO: log error, raise anomaly (or maybe it's the case for XPS?) |
| 426 | # return False | 426 | # return False |
| 427 | + if main_part is None: | ||
| 428 | + # just warn but do not raise an exception. This might be just | ||
| 429 | + # another strange data type out there that we do not understand | ||
| 430 | + # yet. Return False so file type will stay FType_Generic_OpenXML | ||
| 431 | + log.warning('Failed to find any known relationship in OpenXML-file') | ||
| 432 | + return False | ||
| 433 | + | ||
| 427 | # parse content types, find content type of main part | 434 | # parse content types, find content type of main part |
| 428 | try: | 435 | try: |
| 429 | content_types = ftg.zipfile.read('[Content_Types].xml') | 436 | content_types = ftg.zipfile.read('[Content_Types].xml') |