Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find_child_element throughs a Value exception when CAS response contains comments #22

Open
zabano opened this issue May 18, 2023 · 3 comments

Comments

@zabano
Copy link

zabano commented May 18, 2023

tag = etree.QName(child_elm)

The find_child_element function throughs an error when the XML response from the CAS server contains comment objects.
As a workaround I added a test before the line referenced above to check if the element is not a comment.

def find_child_element(elm, child_local_name):
    """
    Find an XML child element by local tag name.
    """
    for n in range(len(elm)):
        child_elm = elm[n]
        if not isinstance(child_elm, etree._Comment):
            tag = etree.QName(child_elm)
            if tag.localname == child_local_name:
                return child_elm
    return None

I am not sure if this is the best way to fix this issue.

@cwaldbieser
Copy link
Owner

cwaldbieser commented Jun 5, 2023

Do you have an example of the CAS XML response I can use for testing? You can redact any personally identifying information.

@cwaldbieser
Copy link
Owner

If you have a particular example, I can make an update and test against it.

@zabano
Copy link
Author

zabano commented Jul 6, 2023

Sorry for the late reply. I will try to get you a deanonymized XML response from CAS as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants