Commit d206212
authored
fix(documentai-toolbox): contain split_pdf output to output_path (#18063)
split_pdf builds each output filename from entity.type_, which is read
straight from the parsed Document (loaded via from_gcs or
from_document_path). Document AI entity types can contain "/" (the
fixtures already carry "vat/tax_amount"), and a document whose type_ is
set to something like ../../../../tmp/pwned makes
os.path.join(output_path, output_filename) write the split PDF outside
output_path. The entity type is now flattened before it goes into the
filename, so the write stays inside output_path.
- [ ] Make sure to open an issue as a
[bug/issue](https://github.com/googleapis/google-cloud-python/issues)
before writing your code! That way we can discuss the change, evaluate
designs, and agree on the general idea
- [x] Ensure the tests and linter pass
- [x] Code coverage does not decrease (if any source code was changed)
- [ ] Appropriate docs were updated (if necessary)1 parent 102c940 commit d206212
2 files changed
Lines changed: 42 additions & 1 deletion
File tree
- packages/google-cloud-documentai-toolbox
- google/cloud/documentai_toolbox/wrappers
- tests/unit
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
823 | 823 | | |
824 | 824 | | |
825 | 825 | | |
826 | | - | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
827 | 837 | | |
828 | 838 | | |
829 | 839 | | |
| |||
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
790 | 790 | | |
791 | 791 | | |
792 | 792 | | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
793 | 824 | | |
794 | 825 | | |
795 | 826 | | |
| |||
0 commit comments