Commit 43c043d370486dc097159f5d52a3e2b942d3c8f7
1 parent
26a592fb
msodde: unify debug-logging what file type we found
Showing
1 changed file
with
12 additions
and
10 deletions
oletools/msodde.py
| ... | ... | @@ -815,7 +815,6 @@ RTF_START = b'\x7b\x5c\x72\x74' # == b'{\rt' but does not mess up auto-indent |
| 815 | 815 | |
| 816 | 816 | |
| 817 | 817 | def process_rtf(file_handle, field_filter_mode=None): |
| 818 | - log.debug('process_rtf') | |
| 819 | 818 | """ find dde links or other fields in rtf file """ |
| 820 | 819 | all_fields = [] |
| 821 | 820 | data = RTF_START + file_handle.read() # read complete file into memory! |
| ... | ... | @@ -843,30 +842,33 @@ def process_rtf(file_handle, field_filter_mode=None): |
| 843 | 842 | |
| 844 | 843 | |
| 845 | 844 | def process_file(filepath, field_filter_mode=None): |
| 846 | - """ decides which of process_doc/x or process_xls/x to call """ | |
| 845 | + """ decides which of the process_* functions to call """ | |
| 847 | 846 | if olefile.isOleFile(filepath): |
| 848 | - log.debug('checking streams to see whether this is xls') | |
| 847 | + log.debug('Is OLE. Checking streams to see whether this is xls') | |
| 849 | 848 | if xls_parser.is_xls(filepath): |
| 849 | + log.debug('Process file as excel 2003 (xls)') | |
| 850 | 850 | return process_xls(filepath) |
| 851 | 851 | else: |
| 852 | + log.debug('Process file as word 2003 (doc)') | |
| 852 | 853 | return process_doc(filepath) |
| 853 | 854 | |
| 854 | 855 | with open(filepath, 'rb') as file_handle: |
| 855 | 856 | if file_handle.read(4) == RTF_START: |
| 856 | - # This is a RTF file | |
| 857 | + log.debug('Process file as rtf') | |
| 857 | 858 | return process_rtf(file_handle, field_filter_mode) |
| 858 | 859 | |
| 859 | 860 | try: |
| 860 | 861 | doctype = ooxml.get_type(filepath) |
| 861 | - except Exception: | |
| 862 | - log.debug('Exception trying to xml-parse file', exc_info=True) | |
| 862 | + log.debug('Detected file type: {0}'.format(doctype)) | |
| 863 | + except Exception as exc: | |
| 864 | + log.debug('Exception trying to xml-parse file: {0}'.format(exc)) | |
| 863 | 865 | doctype = None |
| 864 | 866 | |
| 865 | - if doctype: | |
| 866 | - log.debug('Detected file type: {0}'.format(doctype)) | |
| 867 | 867 | if doctype == ooxml.DOCTYPE_EXCEL: |
| 868 | - return process_xlsx(filepath, field_filter_mode) | |
| 869 | - else: | |
| 868 | + log.debug('Process file as excel 2007+ (xlsx)') | |
| 869 | + return process_xlsx(filepath) | |
| 870 | + else: # could be docx; if not: this is the old default code path | |
| 871 | + log.debug('Process file as word 2007+ (docx)') | |
| 870 | 872 | return process_docx(filepath, field_filter_mode) |
| 871 | 873 | |
| 872 | 874 | ... | ... |