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:
Tony Murray
2019-08-12 09:46:36 -05:00
committed by GitHub
parent cec10c1d37
commit f1c67ac5f4
4 changed files with 38 additions and 8 deletions

View File

@@ -7,9 +7,7 @@ foreach ($_GET as $name => $value) {
$vars[$name] = $value;
}
preg_match('/^(?P<type>[A-Za-z0-9]+)_(?P<subtype>.+)/', $vars['type'], $graphtype);
$type = basename($graphtype['type']);
$subtype = basename($graphtype['subtype']);
list($type, $subtype) = extract_graph_type($vars['type']);
if (is_numeric($vars['device'])) {
$device = device_by_id_cache($vars['device']);