diff --git a/pastepwn/util/templatingengine.py b/pastepwn/util/templatingengine.py index 25b4690..bbb6366 100644 --- a/pastepwn/util/templatingengine.py +++ b/pastepwn/util/templatingengine.py @@ -26,9 +26,7 @@ def fill_template(paste, analyzer_name, template_string, matches=None, **kwargs) paste_dict["matches"] = "" else: # When there are elements in the matches object, we want them to be formatted as single string - matches_str = "" - for element in matches: - matches_str += "{}\n".format(element) + matches_str = "\n".join(matches) paste_dict["matches"] = matches_str # Possibility to insert own/custom values into the paste_dict thus gives more control over the template string diff --git a/pastepwn/util/tests/templatingengine_test.py b/pastepwn/util/tests/templatingengine_test.py index ab92407..6f20993 100644 --- a/pastepwn/util/tests/templatingengine_test.py +++ b/pastepwn/util/tests/templatingengine_test.py @@ -43,7 +43,7 @@ def test_fill_template(self): def test_fill_template_matches(self): """Checks if templating engine inserts the matches correctly into the template""" template = "Matches are: ${matches}" - expected = "Matches are: +123456789\n+987654321\n" + expected = "Matches are: +123456789\n+987654321" matches = ["+123456789", "+987654321"] result = TemplatingEngine.fill_template(paste=self.paste, analyzer_name=None, template_string=template, matches=matches) self.assertEqual(expected, result, msg="Filled template string is not the same as the expected result!")