Skip to content

Commit 92a1faa

Browse files
committed
Do not mess with the value if xs:type is anyType
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent e68435f commit 92a1faa

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/saml2/saml.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ def set_text(self, value, base64encode=False):
209209
}
210210

211211
_type_from_xs_type = {
212-
'xs:anyType': str,
213212
'xs:string': str,
214213
'xs:integer': int,
215214
'xs:short': int,
@@ -219,11 +218,11 @@ def set_text(self, value, base64encode=False):
219218
'xs:double': float,
220219
'xs:boolean': bool,
221220
'xs:base64Binary': str,
221+
'xs:anyType': type(value),
222222
'': type(None),
223223
}
224224

225225
_typed_value_constructor_from_xs_type = {
226-
'xs:anyType': str,
227226
'xs:string': str,
228227
'xs:integer': int,
229228
'xs:short': int,
@@ -236,11 +235,11 @@ def set_text(self, value, base64encode=False):
236235
else False if str(x).lower() == 'false'
237236
else None,
238237
'xs:base64Binary': str,
238+
'xs:anyType': lambda x: value,
239239
'': lambda x: None,
240240
}
241241

242242
_text_constructor_from_xs_type = {
243-
'xs:anyType': str,
244243
'xs:string': str,
245244
'xs:integer': str,
246245
'xs:short': str,
@@ -253,6 +252,7 @@ def set_text(self, value, base64encode=False):
253252
_b64_encode_fn(x.encode())
254253
if base64encode
255254
else x,
255+
'xs:anyType': lambda x: value,
256256
'': lambda x: '',
257257
}
258258

@@ -263,12 +263,7 @@ def set_text(self, value, base64encode=False):
263263
'xs:base64Binary' \
264264
if base64encode \
265265
else self.get_type() \
266-
or _xs_type_from_type.get(type(value))
267-
268-
if xs_type is None:
269-
msg_tpl = 'No corresponding xs-type for {type}:{value}'
270-
msg = msg_tpl.format(type=type(value), value=value)
271-
raise ValueError(msg)
266+
or _xs_type_from_type.get(type(value), type(None))
272267

273268
valid_type = _type_from_xs_type.get(xs_type, type(None))
274269
to_typed = _typed_value_constructor_from_xs_type.get(xs_type, str)

0 commit comments

Comments
 (0)