mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Ports API: Workaround for ifNames with slashes (#10502)
* Workaround for ifNames with slashes Basically, /api/v0/devices/3/ports/0%2f4 -> /api/v0/devices/3/ports/ifName?ifName=0/4 /api/v0/devices/3/ports/0%2f4/port_bits -> /api/v0/devices/3/ports/ifName/port_bits?ifName=0/4 Or you can just use port_id. * Fix API ports using ifName with slashes hand parse the path for the ports graph endpoints this way we can respect the original way of handling slashes (%2F)
This commit is contained in:
@@ -455,6 +455,18 @@ function generate_entity_link($type, $entity, $text = null, $graph_type = null)
|
||||
return ($link);
|
||||
}//end generate_entity_link()
|
||||
|
||||
/**
|
||||
* Extract type and subtype from a complex graph type, also makes sure variables are file name safe.
|
||||
* @param string $type
|
||||
* @return array [type, subtype]
|
||||
*/
|
||||
function extract_graph_type($type): array
|
||||
{
|
||||
preg_match('/^(?P<type>[A-Za-z0-9]+)_(?P<subtype>.+)/', $type, $graphtype);
|
||||
$type = basename($graphtype['type']);
|
||||
$subtype = basename($graphtype['subtype']);
|
||||
return [$type, $subtype];
|
||||
}
|
||||
|
||||
function generate_port_link($port, $text = null, $type = null, $overlib = 1, $single_graph = 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user