Skip to content

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

@nbz6

Description

@nbz6

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUndesired behaviourconfirmedBug is confirm by dev teamresolvedA fixed issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions