Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Don't crash if not organization is defined in the metadata. See bug #…

…931672
  • Loading branch information...
commit f21f1b38771ac8fb6329e6c270db6ade1405a041 1 parent e1e0007
Lorenzo Gil Sanchez lorenzogil authored

Showing 1 changed file with 16 additions and 13 deletions. Show diff stats Hide diff stats

  1. +16 13 src/saml2/metadata.py
29 src/saml2/metadata.py
@@ -678,31 +678,34 @@ def name(self, entity_id):
678 678 """ Find a name from the metadata about this entity id.
679 679 The name is either the display name, the name or the url
680 680 ,in that order, for the organization.
681   -
  681 +
682 682 :param entity_id: The Entity ID
683 683 :return: A name
684 684 """
685 685
686 686 try:
687 687 org = self.entity[entity_id]["organization"]
688   - try:
689   - name = org.organization_display_name[0]
690   - except IndexError:
691   - try:
692   - name = org.organization_name[0]
  688 + if org is None:
  689 + name = ""
  690 + else:
  691 + try:
  692 + name = org.organization_display_name[0]
693 693 except IndexError:
694 694 try:
695   - name = org.organization_url[0]
  695 + name = org.organization_name[0]
696 696 except IndexError:
697   - name = ""
698   -
699   - if name:
700   - name = name.text
  697 + try:
  698 + name = org.organization_url[0]
  699 + except IndexError:
  700 + name = ""
  701 +
  702 + if name:
  703 + name = name.text
701 704 except KeyError:
702 705 name = ""
703   -
  706 +
704 707 return name
705   -
  708 +
706 709 @keep_updated
707 710 def wants(self, entity_id):
708 711 try:

0 comments on commit f21f1b3

Please sign in to comment.
Something went wrong with that request. Please try again.