diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-01-07 16:15:03 -0500 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-01-07 16:15:12 -0500 |
commit | 40bfc1dc57dd6a05a01f72d6332af7d586a15768 (patch) | |
tree | c04413858ff0ba3233f4e4baad02750be3542fe7 | |
parent | dd5dd2cf36d2576112811b211d2b0b02a23e2698 (diff) | |
download | bcfg2-40bfc1dc57dd6a05a01f72d6332af7d586a15768.tar.gz bcfg2-40bfc1dc57dd6a05a01f72d6332af7d586a15768.tar.bz2 bcfg2-40bfc1dc57dd6a05a01f72d6332af7d586a15768.zip |
Cfg: handle filenames with regex special characters properly
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py | 3 | ||||
-rw-r--r-- | testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestCfg/Test_init.py | 1 |
2 files changed, 3 insertions, 1 deletions
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<basename>%s)' % '|'.join(basenames)] + components = ['^(?P<basename>%s)' % '|'.join(re.escape(b) + for b in basenames)] if cls.__specific__: components.append('(|\\.H_(?P<hostname>\S+?)|' + '\.G(?P<prio>\d+)_(?P<group>\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__: |