mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 17:26:10 -06:00
Fixes #11758 - replace unsafe chars in menu label
This commit is contained in:
parent
90ecc86e11
commit
c57030a678
@ -1,5 +1,6 @@
|
|||||||
from netbox.navigation import MenuGroup
|
from netbox.navigation import MenuGroup
|
||||||
from utilities.choices import ButtonColorChoices
|
from utilities.choices import ButtonColorChoices
|
||||||
|
from django.utils.text import slugify
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'PluginMenu',
|
'PluginMenu',
|
||||||
@ -21,18 +22,7 @@ class PluginMenu:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
special_chars = [
|
return slugify(self.label)
|
||||||
' ', '*', '/', '?', '>', '<', '\\', '|', '"', ':',
|
|
||||||
';', ',', '.', '#', '+', '=', '!', '@', '$', '%',
|
|
||||||
'^', '&', '(', ')', '[', ']', '{', '}', '`', '~'
|
|
||||||
]
|
|
||||||
new_name = ''
|
|
||||||
for char in self.label:
|
|
||||||
if char in special_chars:
|
|
||||||
new_name += '_'
|
|
||||||
else:
|
|
||||||
new_name += char
|
|
||||||
return new_name
|
|
||||||
|
|
||||||
|
|
||||||
class PluginMenuItem:
|
class PluginMenuItem:
|
||||||
|
Loading…
Reference in New Issue
Block a user