pypdf
pypdf copied to clipboard
BUG: clean_forms function cause infinite looping if elt["/Resources"] have circular relation
I have several PDF files from customers, and using remove_text can cause infinite looping. Upon investigation, I discovered a corner case where elt["/Resources"] has a circular relation, which can result in calling clean_forms(content, stack + [elt]) infinitely.
I proposed keeping a memory variable visited_resources to keep track of which elt["/Resources"] has been processed and to avoid infinite looping.
The corner case files are private and cannot be shared, but I believe many people would encounter the same problem.