summaryrefslogtreecommitdiff
path: root/src/saml2/saml.py
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2018-09-04 04:12:25 +0300
committerIvan Kanakarakis <ivan.kanak@gmail.com>2018-09-04 04:12:25 +0300
commit92a1faa26848a0711bce54ada086e885745952c0 (patch)
tree8f0e42f0124b3e30eb0346fc49456f09c365eaee /src/saml2/saml.py
parente68435ff74c7efe958c2c1de5c2c0728f0ba99a6 (diff)
downloadpysaml2-92a1faa26848a0711bce54ada086e885745952c0.tar.gz
Do not mess with the value if xs:type is anyType
Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
Diffstat (limited to 'src/saml2/saml.py')
-rw-r--r--src/saml2/saml.py13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/saml2/saml.py b/src/saml2/saml.py
index b4058781..26ada4ad 100644
--- a/src/saml2/saml.py
+++ b/src/saml2/saml.py
@@ -209,7 +209,6 @@ class AttributeValueBase(SamlBase):
}
_type_from_xs_type = {
- 'xs:anyType': str,
'xs:string': str,
'xs:integer': int,
'xs:short': int,
@@ -219,11 +218,11 @@ class AttributeValueBase(SamlBase):
'xs:double': float,
'xs:boolean': bool,
'xs:base64Binary': str,
+ 'xs:anyType': type(value),
'': type(None),
}
_typed_value_constructor_from_xs_type = {
- 'xs:anyType': str,
'xs:string': str,
'xs:integer': int,
'xs:short': int,
@@ -236,11 +235,11 @@ class AttributeValueBase(SamlBase):
else False if str(x).lower() == 'false'
else None,
'xs:base64Binary': str,
+ 'xs:anyType': lambda x: value,
'': lambda x: None,
}
_text_constructor_from_xs_type = {
- 'xs:anyType': str,
'xs:string': str,
'xs:integer': str,
'xs:short': str,
@@ -253,6 +252,7 @@ class AttributeValueBase(SamlBase):
_b64_encode_fn(x.encode())
if base64encode
else x,
+ 'xs:anyType': lambda x: value,
'': lambda x: '',
}
@@ -263,12 +263,7 @@ class AttributeValueBase(SamlBase):
'xs:base64Binary' \
if base64encode \
else self.get_type() \
- or _xs_type_from_type.get(type(value))
-
- if xs_type is None:
- msg_tpl = 'No corresponding xs-type for {type}:{value}'
- msg = msg_tpl.format(type=type(value), value=value)
- raise ValueError(msg)
+ or _xs_type_from_type.get(type(value), type(None))
valid_type = _type_from_xs_type.get(xs_type, type(None))
to_typed = _typed_value_constructor_from_xs_type.get(xs_type, str)