pypdf icon indicating copy to clipboard operation
pypdf copied to clipboard

BUG: clean_forms function cause infinite looping if elt["/Resources"] have circular relation

Open syan-dev opened this issue 1 year ago • 0 comments

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.

syan-dev avatar Feb 27 '24 10:02 syan-dev