Dolibarr / dolibarr

Dolibarr ERP CRM is a modern software package to manage your company or foundation's activity (contacts, suppliers, invoices, orders, stocks, agenda, accounting, ...). it's an open source Web application (written in PHP) designed for businesses of any sizes, foundations and freelancers.
https://www.dolibarr.org
GNU General Public License v3.0
5.26k stars 2.73k forks source link

import.class.php has incorrect module file filter #30732

Open ouch67 opened 3 weeks ago

ouch67 commented 3 weeks ago

Bug

When creating a new module in Dolibar v19.0.2 and setting an import profile in the module's modX.class.php it gets duplicated on the import step 1 screen. This happens because the built in file editor creates a backup file and the import.class.php file has an incorrect file filter set.

import.class.php Line 117 currently looks like this: /^(mod.*)\.class\.php/i It needs a $ added after .PHP to look like: /^(mod.*)\.class\.php$/i

This would bring this module to match export.class.php line 128's class file filter. Which does not have any issues.

Dolibarr Version

19.0.2

Environment PHP

8.2.21

Environment Database

posgresql 16

Steps to reproduce the behavior and expected behavior

No response

Attached files

No response

ksar-ksar commented 2 weeks ago

Hello,

Thanks for your investigations. Can you make a PR ?

ouch67 commented 2 weeks ago

I do not have git at work but you only need to change line 198 of import.class.php from the main branch to:

if (!preg_match("/^(mod.*)\.class\.php$/i", $file, $reg)) { Essentially just adding the '$' after '.php'