diff --git a/tests/plugins/test_spaces_in_filename.py b/tests/plugins/test_spaces_in_filename.py index 256fdc9f..9badce93 100644 --- a/tests/plugins/test_spaces_in_filename.py +++ b/tests/plugins/test_spaces_in_filename.py @@ -25,5 +25,5 @@ def test_fail(self): self.assertIsInstance(results[0], LinterError) self.assertEqual( results[0].message, - f"The VT {nasl_file} contains spaces in the filename", + f"The VT {nasl_file} contains whitespace in the filename", ) diff --git a/troubadix/plugins/spaces_in_filename.py b/troubadix/plugins/spaces_in_filename.py index 95fd8f7c..90dbc38b 100644 --- a/troubadix/plugins/spaces_in_filename.py +++ b/troubadix/plugins/spaces_in_filename.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: 2024 Greenbone AG +import re from typing import Iterator from troubadix.plugin import FilePlugin, LinterError, LinterResult @@ -10,10 +11,10 @@ class CheckSpacesInFilename(FilePlugin): name = "check_spaces_in_filename" def run(self) -> Iterator[LinterResult]: - if " " in self.context.nasl_file.name: + if re.search(r"\s", self.context.nasl_file.name): yield LinterError( f"The VT {self.context.nasl_file}" - " contains spaces in the filename", + " contains whitespace in the filename", file=self.context.nasl_file, plugin=self.name, )