From 714619eefb61c5a0c86ba78c01f5c1b41a1e23b7 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Fri, 22 Mar 2024 22:04:30 -0400 Subject: [PATCH] :beetle: protect against bad filenames with multiple `.c` instances in them (#348) --- lib/cmock_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cmock_generator.rb b/lib/cmock_generator.rb index 1e710555..dfbe3e26 100644 --- a/lib/cmock_generator.rb +++ b/lib/cmock_generator.rb @@ -208,7 +208,7 @@ def create_mock_header_footer(header) end def create_source_header_section(file, filename, mock_project) - header_file = (mock_project[:folder] || '') + filename.gsub('.c', mock_project[:module_ext]) + header_file = (mock_project[:folder] || '') + filename.sub(/.*\K\.c/, mock_project[:module_ext]) file << "/* AUTOGENERATED FILE. DO NOT EDIT. */\n" unless mock_project[:parsed_stuff][:functions].empty? file << "#include \n" file << "#include \n"