Skip to content

Commit 2d72200

Browse files
committed
fix: limit text literal in provenance to 1MB
1 parent ad4e151 commit 2d72200

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

nipype/utils/provenance.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
get_id = lambda: niiri[uuid1().hex]
2323

24+
max_text_len = 1024000
25+
2426
def safe_encode(x):
2527
"""Encodes a python value for prov
2628
"""
@@ -35,7 +37,11 @@ def safe_encode(x):
3537
return pm.Literal('file://%s%s' % (getfqdn(), x),
3638
pm.XSD['anyURI'])
3739
else:
38-
return pm.Literal(x, pm.XSD['string'])
40+
if len(x) > max_text_len:
41+
return pm.Literal(x[:max_text_len - 13] + ['...Clipped...'],
42+
pm.XSD['string'])
43+
else:
44+
return pm.Literal(x, pm.XSD['string'])
3945
if isinstance(x, (int,)):
4046
return pm.Literal(int(x), pm.XSD['integer'])
4147
if isinstance(x, (float,)):

0 commit comments

Comments
 (0)