Skip to content

Commit 21ecea0

Browse files
author
viacheslav diomidov
committed
BUGFIX EXTREST-137 simpleXml fix for & in values.
1 parent 8ad7345 commit 21ecea0

17 files changed

+35
-30
lines changed

src/Api/Client.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,15 @@ protected function _expandRequestShortSyntax($request, SimpleXMLElement $xml)
321321
{
322322
$parts = explode('.', $request);
323323
$node = $xml;
324+
$lastParts = end($parts);
324325

325326
foreach ($parts as $part) {
326327
@list($name, $value) = explode('=', $part);
327-
$node = $node->addChild($name, $value);
328+
if ($part !== $lastParts) {
329+
$node = $node->addChild($name);
330+
} else {
331+
$node->{$name} = (string) $value;
332+
}
328333
}
329334

330335
return $xml->asXML();
@@ -346,7 +351,7 @@ protected function _arrayToXml(array $array, SimpleXMLElement $xml, $parentEl =
346351
if (is_array($value)) {
347352
$this->_arrayToXml($value, $this->_isAssocArray($value) ? $xml->addChild($el) : $xml, $el);
348353
} else {
349-
$xml->addChild($el, $value);
354+
$xml->{$el} = (string) $value;
350355
}
351356
}
352357

src/Api/Operator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected function _getItems($structClass, $infoTag, $field = null, $value = nul
7878

7979
$filterTag = $getTag->addChild('filter');
8080
if (!is_null($field)) {
81-
$filterTag->addChild($field, $value);
81+
$filterTag->{$field} = $value;
8282
}
8383

8484
$getTag->addChild('dataset')->addChild($infoTag);

src/Api/Operator/Certificate.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function generate($properties)
1818
$info = $packet->addChild($this->_wrapperTag)->addChild('generate')->addChild('info');
1919

2020
foreach ($properties as $name => $value) {
21-
$info->addChild($name, $value);
21+
$info->{$name} = $value;
2222
}
2323

2424
$response = $this->_client->request($packet);

src/Api/Operator/Customer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function create($properties)
1818
$info = $packet->addChild($this->_wrapperTag)->addChild('add')->addChild('gen_info');
1919

2020
foreach ($properties as $name => $value) {
21-
$info->addChild($name, $value);
21+
$info->{$name} = $value;
2222
}
2323

2424
$response = $this->_client->request($packet);

src/Api/Operator/Database.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private function _process($command, array $properties)
4343
$info->$name = $value;
4444
continue;
4545
}
46-
$info->addChild($name, $value);
46+
$info->{$name} = $value;
4747
}
4848

4949
return $this->_client->request($packet);
@@ -135,7 +135,7 @@ private function _get($command, $field, $value)
135135

136136
$filterTag = $getTag->addChild('filter');
137137
if (!is_null($field)) {
138-
$filterTag->addChild($field, $value);
138+
$filterTag->{$field} = $value;
139139
}
140140

141141
$response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);

src/Api/Operator/DatabaseServer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private function _get($field = null, $value = null)
5353

5454
$filterTag = $getTag->addChild('filter');
5555
if (!is_null($field)) {
56-
$filterTag->addChild($field, $value);
56+
$filterTag->{$field} = $value;
5757
}
5858

5959
$response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);

src/Api/Operator/Dns.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function create($properties)
1818
$info = $packet->addChild($this->_wrapperTag)->addChild('add_rec');
1919

2020
foreach ($properties as $name => $value) {
21-
$info->addChild($name, $value);
21+
$info->{$name} = $value;
2222
}
2323

2424
return new Struct\Info($this->_client->request($packet));
@@ -39,7 +39,7 @@ public function bulkCreate(array $records)
3939
$info = $packet->addChild($this->_wrapperTag)->addChild('add_rec');
4040

4141
foreach ($properties as $name => $value) {
42-
$info->addChild($name, $value);
42+
$info->{$name} = $value;
4343
}
4444
}
4545

src/Api/Operator/DnsTemplate.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function create(array $properties)
2121

2222
unset($properties['site-id'], $properties['site-alias-id']);
2323
foreach ($properties as $name => $value) {
24-
$info->addChild($name, $value);
24+
$info->{$name} = $value;
2525
}
2626

2727
return new Struct\Info($this->_client->request($packet));
@@ -53,7 +53,7 @@ public function getAll($field = null, $value = null)
5353

5454
$filterTag = $getTag->addChild('filter');
5555
if (!is_null($field)) {
56-
$filterTag->addChild($field, $value);
56+
$filterTag->{$field} = $value;
5757
}
5858
$getTag->addChild('template');
5959

src/Api/Operator/Mail.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function create($name, $siteId, $mailbox = false, $password = '')
2828
$mailname->addChild('mailbox')->addChild('enabled', 'true');
2929
}
3030
if (!empty($password)) {
31-
$mailname->addChild('password')->addChild('value', $password);
31+
$mailname->addChild('password')->value = $password;
3232
}
3333

3434
$response = $this->_client->request($packet);
@@ -48,7 +48,7 @@ public function delete($field, $value, $siteId)
4848
$packet = $this->_client->getPacket();
4949
$filter = $packet->addChild($this->_wrapperTag)->addChild('remove')->addChild('filter');
5050
$filter->addChild('site-id', $siteId);
51-
$filter->addChild($field, $value);
51+
$filter->{$field} = $value;
5252
$response = $this->_client->request($packet);
5353

5454
return 'ok' === (string) $response->status;

src/Api/Operator/ProtectedDirectory.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ public function addUser($protectedDirectory, $login, $password)
8181
$packet = $this->_client->getPacket();
8282
$info = $packet->addChild($this->_wrapperTag)->addChild('add-user');
8383

84-
$info->addChild('pd-id', $protectedDirectory->id);
85-
$info->addChild('login', $login);
86-
$info->addChild('password', $password);
84+
$info->{'pd-id'} = $protectedDirectory->id;
85+
$info->login = $login;
86+
$info->password = $password;
8787

8888
return new Struct\UserInfo($this->_client->request($packet));
8989
}
@@ -113,7 +113,7 @@ private function _get($command, $field, $value)
113113

114114
$filterTag = $getTag->addChild('filter');
115115
if (!is_null($field)) {
116-
$filterTag->addChild($field, $value);
116+
$filterTag->{$field} = $value;
117117
}
118118

119119
$response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);

src/Api/Operator/Reseller.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function create($properties)
1818
$info = $packet->addChild($this->_wrapperTag)->addChild('add')->addChild('gen-info');
1919

2020
foreach ($properties as $name => $value) {
21-
$info->addChild($name, $value);
21+
$info->{$name} = $value;
2222
}
2323

2424
$response = $this->_client->request($packet);

src/Api/Operator/Site.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ public function create(array $properties)
2424
if (!is_scalar($value)) {
2525
continue;
2626
}
27-
$infoGeneral->addChild($name, $value);
27+
$infoGeneral->{$name} = $value;
2828
}
2929

3030
// set hosting properties
3131
if (isset($properties[static::PROPERTIES_HOSTING]) && is_array($properties[static::PROPERTIES_HOSTING])) {
3232
$hostingNode = $info->addChild('hosting')->addChild('vrt_hst');
3333
foreach ($properties[static::PROPERTIES_HOSTING] as $name => $value) {
3434
$propertyNode = $hostingNode->addChild('property');
35-
$propertyNode->addChild('name', $name);
36-
$propertyNode->addChild('value', $value);
35+
$propertyNode->name = $name;
36+
$propertyNode->value = $value;
3737
}
3838
}
3939

src/Api/Operator/SiteAlias.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function getAll($field = null, $value = null)
7171

7272
$filterTag = $getTag->addChild('filter');
7373
if (!is_null($field)) {
74-
$filterTag->addChild($field, $value);
74+
$filterTag->{$field} = $value;
7575
}
7676

7777
$response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);

src/Api/Operator/Subdomain.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public function create($properties)
2121
if (is_array($value)) {
2222
foreach ($value as $propertyName => $propertyValue) {
2323
$property = $info->addChild($name);
24-
$property->addChild('name', $propertyName);
25-
$property->addChild('value', $propertyValue);
24+
$property->name = $propertyName;
25+
$property->value = $propertyValue;
2626
}
2727
continue;
2828
}
29-
$info->addChild($name, $value);
29+
$info->{$name} = $value;
3030
}
3131

3232
$response = $this->_client->request($packet);

src/Api/Operator/Ui.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function createCustomButton($owner, $properties)
3131
$propertiesNode = $buttonNode->addChild('properties');
3232

3333
foreach ($properties as $name => $value) {
34-
$propertiesNode->addChild($name, $value);
34+
$propertiesNode->{$name} = $value;
3535
}
3636

3737
$response = $this->_client->request($packet);

src/Api/Operator/Webspace.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ public function create(array $properties, array $hostingProperties = null, strin
8282
$infoHosting = $info->addChild('hosting')->addChild('vrt_hst');
8383
foreach ($hostingProperties as $name => $value) {
8484
$property = $infoHosting->addChild('property');
85-
$property->addChild('name', $name);
86-
$property->addChild('value', $value);
85+
$property->name = $name;
86+
$property->value = $value;
8787
}
8888

8989
if (isset($properties['ip_address'])) {

tests/Utility/PasswordProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55

66
class PasswordProvider
77
{
8-
const STRONG_PASSWORD = 'test-PWD*1@42!13#';
8+
const STRONG_PASSWORD = 'test-&PWD*1@42!13#';
99
}

0 commit comments

Comments
 (0)