Bad URL formating in the templates_import.php preview mode
Describe the bug
In Cacti 1.2.26 with a configuration where the $url_path = '/'; if you try to import a template XML file, the requested URL won't work as it will be format like that : https://templates_import.php/?preview_only=true And browser will block it.
This issue have been previously discuted on the Cacti forum : https://forums.cacti.net/viewtopic.php?t=63036
To Reproduce
Steps to reproduce the behavior:
-
Prerequisites : $url_path = '/';
-
Go to 'import/export' in the admin, then in 'import a template'
-
Click on 'Select a file' and choose a XML file
-
The preview mode will not load
-
See error in the console dev tools of the browser
Expected behavior
The preview mode should be working if the requested URL is well formated.
Screenshots
Additional context
I have tested the proposed fix by @TheWitness :
Edit line 490 in templates_import.php and change
url: urlPath + '/templates_import.php?preview_only=true',
to:
url: (urlPath != '/' ? urlPath + '/':'') + 'templates_import.php?preview_only=true',
And it's working great now, the preview page is displayed without error.
Thank you