Cacti / cacti

Cacti ™
http://www.cacti.net
GNU General Public License v2.0
1.6k stars 398 forks source link

When importing templates, preview mode will not always load #5701

Closed nbz6 closed 3 months ago

nbz6 commented 3 months ago

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:

  1. Prerequisites : $url_path = '/';

  2. Go to 'import/export' in the admin, then in 'import a template'

  3. Click on 'Select a file' and choose a XML file

  4. The preview mode will not load

  5. 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

image

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

TheWitness commented 3 months ago

Thanks for reporting and confirming on this one. Will be in 1.2.27.