factur-x icon indicating copy to clipboard operation
factur-x copied to clipboard

Error in programming logic

Open JordyScript opened this issue 4 years ago • 0 comments

I had a look through the source code to learn more about PyPDF4 usage, and found line 206 in facturx.py to be suspicious. It looks like a logical error, and hence a bug.

Apparently the intent of the level parameter is to limit recursion depth, but as it stands the line in question does no such thing.

def _parse_embeddedfiles_kids_node(kids_node, level, res):
    ... # lines omitted
       _parse_embeddedfiles_kids_node(kids_node_l2, 2, res)

This is the line in the fuction _parse_embeddedfiles_kids_node that does the recursion, but instead of dynamically increasing the 2nd argument, level is hardcoded as being 2.

The following line would fix the bug.

_parse_embeddedfiles_kids_node(kids_node_l2, level + 1, res)

Unless I have misunderstood the code, I think this problem exists and can be fixed in the manner I suggested.

JordyScript avatar Aug 16 '20 15:08 JordyScript