From fd0650aef3de47be12112937a09ca0380c8c1bb2 Mon Sep 17 00:00:00 2001 From: Daniel <d.hornung@indiscale.com> Date: Wed, 22 May 2024 14:00:29 +0200 Subject: [PATCH] FIX: No infinite recursion for 1-character strings. --- src/linkahead/common/models.py | 4 ++-- unittests/test_issues.py | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/linkahead/common/models.py b/src/linkahead/common/models.py index 483c5231..9df9788e 100644 --- a/src/linkahead/common/models.py +++ b/src/linkahead/common/models.py @@ -1709,8 +1709,8 @@ def _parse_value(datatype, value): return ret # This is for a special case, where the xml parser could not differentiate - # between single values and lists with one element. As - if hasattr(value, "__len__") and len(value) == 1: + # between single values and lists with one element. + if hasattr(value, "__len__") and not isinstance(value, str) and len(value) == 1: return _parse_value(datatype, value[0]) # deal with references diff --git a/unittests/test_issues.py b/unittests/test_issues.py index 7472f710..ba934009 100644 --- a/unittests/test_issues.py +++ b/unittests/test_issues.py @@ -64,3 +64,9 @@ def test_issue_156(): # </ParentList> assert value is project assert parents[0].name == "RTName" + + +def test_parse_datatype(): + """No infinite recursion.""" + from linkahead.common.models import _parse_value + assert 1 == _parse_value("labels0", "1") -- GitLab