Skip to content

Commit 07766ae

Browse files
committed
fix: URL encode variables passed to API
1 parent 809b676 commit 07766ae

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

apis/upcloudvps_api.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public function GetAllServers()
221221
*/
222222
public function GetServer($ServerUUID)
223223
{
224-
return $this->get('server/' . $ServerUUID);
224+
return $this->get('server/' . rawurlencode($ServerUUID));
225225
}
226226

227227
/**
@@ -305,7 +305,7 @@ public function serverOperation($action, $ServerUUID, $stop_type = null)
305305
$data[$action . '_server']['stop_type'] = $stop_type;
306306
$data[$action . '_server']['timeout'] = "60";
307307
}
308-
return $this->post('server/' . $ServerUUID . '/' . $action, $data);
308+
return $this->post(sprintf('server/%s/%s', rawurlencode($ServerUUID), rawurlencode($action)), $data);
309309
}
310310

311311
/**
@@ -360,7 +360,7 @@ public function CancelServer($ServerUUID)
360360
*/
361361
public function DeleteServer($ServerUUID)
362362
{
363-
return $this->delete('server/' . $ServerUUID);
363+
return $this->delete('server/' . rawurlencode($ServerUUID));
364364
}
365365

366366
/**
@@ -382,7 +382,7 @@ public function ModifyServer($uuid, $Plan)
382382
}
383383
}
384384

385-
$upgradePlan = $this->put('server/' . $uuid, ['server' => ['plan' => $Plan]]);
385+
$upgradePlan = $this->put('server/' . rawurlencode($uuid), ['server' => ['plan' => $Plan]]);
386386
if ($upgradePlan['response']['error']['error_message']) {
387387
return $upgradePlan;
388388
} else {
@@ -417,7 +417,7 @@ public function modifyStorage($storageId, $planSize)
417417
'size' => $planSize
418418
]
419419
];
420-
return $this->put('storage/' . $storageId, $body);
420+
return $this->put('storage/' . rawurlencode($storageId), $body);
421421
}
422422

423423
/**
@@ -430,7 +430,7 @@ public function modifyStorage($storageId, $planSize)
430430
public function DeleteServerAndStorage($ServerUUID)
431431
{
432432
$this->stopServerAndWait($ServerUUID);
433-
return $this->delete('server/' . $ServerUUID . '?storages=1');
433+
return $this->delete(sprintf('server/%s?storages=1', rawurlencode($ServerUUID)));
434434
}
435435

436436
/**
@@ -443,7 +443,7 @@ public function DeleteServerAndStorage($ServerUUID)
443443
public function DeleteServerAndStorageAndBackups($ServerUUID)
444444
{
445445
$this->stopServerAndWait($ServerUUID);
446-
return $this->delete('server/' . $ServerUUID . '?storages=1&backups=delete');
446+
return $this->delete(sprintf('server/%s?storages=1&backups=delete', rawurlencode($ServerUUID)));
447447
}
448448

449449
/**
@@ -481,7 +481,7 @@ public function stopServerAndWait($ServerUUID)
481481
*/
482482
public function GetIPaddress($IPAddress)
483483
{
484-
return $this->get('ip_address/' . $IPAddress);
484+
return $this->get('ip_address/' . rawurlencode($IPAddress));
485485
}
486486

487487
/**
@@ -497,7 +497,7 @@ public function ModifyIPaddress($instanceId, $IP, $ptr_record)
497497
if (!($this->GetIPaddress($IP)['response']['ip_address']['server'] == $instanceId)) {
498498
$this->logger->error('IP does not belong to your server');
499499
}
500-
return $this->put('ip_address/' . $IP, ['ip_address' => ['ptr_record' => $ptr_record]]);
500+
return $this->put('ip_address/' . rawurlencode($IP), ['ip_address' => ['ptr_record' => $ptr_record]]);
501501
}
502502

503503

@@ -510,7 +510,7 @@ public function ModifyIPaddress($instanceId, $IP, $ptr_record)
510510
*/
511511
public function vncPasswordUpdate($instanceId, $vncPass)
512512
{
513-
return $this->put('server/' . $instanceId, ['server' => ['remote_access_password' => $vncPass]]);
513+
return $this->put('server/' . rawurlencode($instanceId), ['server' => ['remote_access_password' => $vncPass]]);
514514
}
515515

516516
/**
@@ -522,7 +522,7 @@ public function vncPasswordUpdate($instanceId, $vncPass)
522522
*/
523523
public function vncEnableDisable($instanceId, $vncType)
524524
{
525-
return $this->put('server/' . $instanceId, ['server' => ['remote_access_enabled' => $vncType]]);
525+
return $this->put('server/' . rawurlencode($instanceId), ['server' => ['remote_access_enabled' => $vncType]]);
526526
}
527527

528528
/**
@@ -534,7 +534,7 @@ public function vncEnableDisable($instanceId, $vncType)
534534
*/
535535
public function modifyVPS($instanceId, $serverConfig)
536536
{
537-
return $this->put('server/' . $instanceId, $serverConfig);
537+
return $this->put('server/' . rawurlencode($instanceId), $serverConfig);
538538
}
539539

540540
/**

0 commit comments

Comments
 (0)