Commit eafe4d928e496dfde0e021ce5df08adb031f6eb0
Committed by
Philippe Lagadec
1 parent
1f3a02a7
msodde: rename functions *_ole_* to *_doc_*
Showing
1 changed file
with
13 additions
and
12 deletions
oletools/msodde.py
| ... | ... | @@ -369,7 +369,7 @@ def process_args(cmd_line_args=None): |
| 369 | 369 | # separator are collectively referred to as field characters. |
| 370 | 370 | |
| 371 | 371 | |
| 372 | -def process_ole_field(data): | |
| 372 | +def process_doc_field(data): | |
| 373 | 373 | """ check if field instructions start with DDE |
| 374 | 374 | |
| 375 | 375 | expects unicode input, returns unicode output (empty if not dde) """ |
| ... | ... | @@ -390,11 +390,11 @@ OLE_FIELD_END = 0x15 |
| 390 | 390 | OLE_FIELD_MAX_SIZE = 1000 # max field size to analyze, rest is ignored |
| 391 | 391 | |
| 392 | 392 | |
| 393 | -def process_ole_stream(stream): | |
| 394 | - """ find dde links in single ole stream | |
| 393 | +def process_doc_stream(stream): | |
| 394 | + """ find dde links in single word ole stream | |
| 395 | 395 | |
| 396 | - since ole file stream are subclasses of io.BytesIO, they are buffered, so | |
| 397 | - reading char-wise is not that bad performanc-wise """ | |
| 396 | + since word ole file stream are subclasses of io.BytesIO, they are buffered, | |
| 397 | + so reading char-wise is not that bad performanc-wise """ | |
| 398 | 398 | |
| 399 | 399 | have_start = False |
| 400 | 400 | have_sep = False |
| ... | ... | @@ -428,7 +428,7 @@ def process_ole_stream(stream): |
| 428 | 428 | have_sep = True |
| 429 | 429 | elif char == OLE_FIELD_END: |
| 430 | 430 | # have complete field now, process it |
| 431 | - new_result = process_ole_field(field_contents) | |
| 431 | + new_result = process_doc_field(field_contents) | |
| 432 | 432 | if new_result: |
| 433 | 433 | result_parts.append(new_result) |
| 434 | 434 | |
| ... | ... | @@ -468,15 +468,15 @@ def process_ole_stream(stream): |
| 468 | 468 | return result_parts |
| 469 | 469 | |
| 470 | 470 | |
| 471 | -def process_ole(filepath): | |
| 471 | +def process_doc(filepath): | |
| 472 | 472 | """ |
| 473 | - find dde links in ole file | |
| 473 | + find dde links in word ole (.doc/.dot) file | |
| 474 | 474 | |
| 475 | 475 | like process_xml, returns a concatenated unicode string of dde links or |
| 476 | 476 | empty if none were found. dde-links will still begin with the dde[auto] key |
| 477 | 477 | word (possibly after some whitespace) |
| 478 | 478 | """ |
| 479 | - log.debug('process_ole') | |
| 479 | + log.debug('process_doc') | |
| 480 | 480 | ole = olefile.OleFileIO(filepath, path_encoding=None) |
| 481 | 481 | |
| 482 | 482 | links = [] |
| ... | ... | @@ -493,7 +493,7 @@ def process_ole(filepath): |
| 493 | 493 | 'no stream ({})' |
| 494 | 494 | .format(direntry.entry_type))) |
| 495 | 495 | if is_stream: |
| 496 | - new_parts = process_ole_stream( | |
| 496 | + new_parts = process_doc_stream( | |
| 497 | 497 | ole._open(direntry.isectStart, direntry.size)) |
| 498 | 498 | links.extend(new_parts) |
| 499 | 499 | |
| ... | ... | @@ -501,6 +501,7 @@ def process_ole(filepath): |
| 501 | 501 | return u'\n'.join(links) |
| 502 | 502 | |
| 503 | 503 | |
| 504 | + | |
| 504 | 505 | def process_xls(filepath): |
| 505 | 506 | """ find dde links in excel ole file """ |
| 506 | 507 | |
| ... | ... | @@ -719,12 +720,12 @@ def process_xlsx(filepath, filed_filter_mode=None): |
| 719 | 720 | |
| 720 | 721 | |
| 721 | 722 | def process_file(filepath, field_filter_mode=None): |
| 722 | - """ decides to either call process_docx or process_ole or process_xlsx """ | |
| 723 | + """ decides which of process_doc/x or process_xls/x to call """ | |
| 723 | 724 | if olefile.isOleFile(filepath): |
| 724 | 725 | if xls_parser.is_xls(filepath): |
| 725 | 726 | return process_xls(filepath) |
| 726 | 727 | else: |
| 727 | - return process_ole(filepath) | |
| 728 | + return process_doc(filepath) | |
| 728 | 729 | try: |
| 729 | 730 | doctype = ooxml.get_type(filepath) |
| 730 | 731 | log.debug('Detected file type: {0}'.format(doctype)) | ... | ... |