Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…931672
  • Loading branch information...
commit f21f1b38771ac8fb6329e6c270db6ade1405a041 1 parent e1e0007
@lorenzogil lorenzogil authored
Showing with 16 additions and 13 deletions.
  1. +16 −13 src/saml2/metadata.py
View
29 src/saml2/metadata.py
@@ -678,31 +678,34 @@ def name(self, entity_id):
""" Find a name from the metadata about this entity id.
The name is either the display name, the name or the url
,in that order, for the organization.
-
+
:param entity_id: The Entity ID
:return: A name
"""
try:
org = self.entity[entity_id]["organization"]
- try:
- name = org.organization_display_name[0]
- except IndexError:
- try:
- name = org.organization_name[0]
+ if org is None:
+ name = ""
+ else:
+ try:
+ name = org.organization_display_name[0]
except IndexError:
try:
- name = org.organization_url[0]
+ name = org.organization_name[0]
except IndexError:
- name = ""
-
- if name:
- name = name.text
+ try:
+ name = org.organization_url[0]
+ except IndexError:
+ name = ""
+
+ if name:
+ name = name.text
except KeyError:
name = ""
-
+
return name
-
+
@keep_updated
def wants(self, entity_id):
try:
Please sign in to comment.
Something went wrong with that request. Please try again.