akretion / factur-x

Python lib for Factur-X, the e-invoicing standard for France and Germany
Other
156 stars 56 forks source link

Error in programming logic #19

Closed JordyScript closed 1 year ago

JordyScript commented 4 years ago

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.

alexis-via commented 1 year ago

I confirm the code. Your suggestion would not change anything because we are in a if with level==1.