From 111ba0e949ce14d764ab86c3a477d536229220e5 Mon Sep 17 00:00:00 2001 From: Ron Eldor Date: Sun, 18 Nov 2018 17:05:05 +0200 Subject: [PATCH] Fix parsing error of test data Fix parsing error that contains special character. The previous implementation replaced the `:` char with `\n`, and split on `\n`. Test data containing strings with `\n` were split as well. Fixes #2193. The split function caused strings containing `\:` to add another escape char, resulting in `\\:`. This caused the tests with the `\:` in the string data to fail. The fix doesn't replace with `\n`, but splits all `:` that are not preceded with `\`. After that, removes the preceding `\` char. --- tests/scripts/mbedtls_test.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/scripts/mbedtls_test.py b/tests/scripts/mbedtls_test.py index 8e8a89ba9..ea85700af 100755 --- a/tests/scripts/mbedtls_test.py +++ b/tests/scripts/mbedtls_test.py @@ -75,11 +75,10 @@ class TestDataParser(object): :param split_char: Split character :return: List of splits """ + split_colon_fn = lambda x: re.sub(r'\\' + split_char, split_char, x) if len(split_char) > 1: raise ValueError('Expected split character. Found string!') - out = re.sub(r'(\\.)|' + split_char, - lambda m: m.group(1) or '\n', inp_str, - len(inp_str)).split('\n') + out = map(split_colon_fn, re.split(r'(?