From 40bfc1dc57dd6a05a01f72d6332af7d586a15768 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Mon, 7 Jan 2013 16:15:03 -0500 Subject: Cfg: handle filenames with regex special characters properly --- src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py | 3 ++- testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestCfg/Test_init.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py index 733eb1941..fcfaa393b 100644 --- a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py +++ b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py @@ -108,7 +108,8 @@ class CfgBaseFileMatcher(Bcfg2.Server.Plugin.SpecificData, :type basename: string :returns: compiled regex """ - components = ['^(?P%s)' % '|'.join(basenames)] + components = ['^(?P%s)' % '|'.join(re.escape(b) + for b in basenames)] if cls.__specific__: components.append('(|\\.H_(?P\S+?)|' + '\.G(?P\d+)_(?P\S+?))') diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestCfg/Test_init.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestCfg/Test_init.py index 55fbb7446..2e758774e 100644 --- a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestCfg/Test_init.py +++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestCfg/Test_init.py @@ -24,6 +24,7 @@ from TestPlugin import TestSpecificData, TestEntrySet, TestGroupSpool, \ class TestCfgBaseFileMatcher(TestSpecificData): test_obj = CfgBaseFileMatcher + path = os.path.join(datastore, "test+test.txt") def test_get_regex(self): if self.test_obj.__basenames__: -- cgit v1.2.3-1-g7c22