Skip to content

Commit 9df581f

Browse files
author
viacheslav diomidov
committed
BUGFIX PPP-54497 simpleXml fix for & in values
1 parent 8ad7345 commit 9df581f

17 files changed

+25
-23
lines changed

Diff for: src/Api/Client.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ protected function _expandRequestShortSyntax($request, SimpleXMLElement $xml)
324324

325325
foreach ($parts as $part) {
326326
@list($name, $value) = explode('=', $part);
327-
$node = $node->addChild($name, $value);
327+
$node->{$name} = $value;
328328
}
329329

330330
return $xml->asXML();
@@ -346,7 +346,7 @@ protected function _arrayToXml(array $array, SimpleXMLElement $xml, $parentEl =
346346
if (is_array($value)) {
347347
$this->_arrayToXml($value, $this->_isAssocArray($value) ? $xml->addChild($el) : $xml, $el);
348348
} else {
349-
$xml->addChild($el, $value);
349+
$node = $node->addChild($el, htmlspecialchars($value));
350350
}
351351
}
352352

Diff for: 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);

Diff for: 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);

Diff for: 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);

Diff for: src/Api/Operator/Database.php

+2-1
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);
@@ -136,6 +136,7 @@ private function _get($command, $field, $value)
136136
$filterTag = $getTag->addChild('filter');
137137
if (!is_null($field)) {
138138
$filterTag->addChild($field, $value);
139+
$filterTag->{$field} = $value;
139140
}
140141

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

Diff for: 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);

Diff for: 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

Diff for: 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

Diff for: 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')->addChild('value', htmlspecialchars($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;

Diff for: src/Api/Operator/ProtectedDirectory.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function addUser($protectedDirectory, $login, $password)
8383

8484
$info->addChild('pd-id', $protectedDirectory->id);
8585
$info->addChild('login', $login);
86-
$info->addChild('password', $password);
86+
$info->addChild('password', htmlspecialchars($password));
8787

8888
return new Struct\UserInfo($this->_client->request($packet));
8989
}
@@ -114,6 +114,7 @@ private function _get($command, $field, $value)
114114
$filterTag = $getTag->addChild('filter');
115115
if (!is_null($field)) {
116116
$filterTag->addChild($field, $value);
117+
$filterTag->{$field} = $value;
117118
}
118119

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

Diff for: 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);

Diff for: src/Api/Operator/Site.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ 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
@@ -33,7 +33,7 @@ public function create(array $properties)
3333
foreach ($properties[static::PROPERTIES_HOSTING] as $name => $value) {
3434
$propertyNode = $hostingNode->addChild('property');
3535
$propertyNode->addChild('name', $name);
36-
$propertyNode->addChild('value', $value);
36+
$propertyNode->addChild('value', htmlspecialchars($value));
3737
}
3838
}
3939

Diff for: 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);

Diff for: src/Api/Operator/Subdomain.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ public function create($properties)
2222
foreach ($value as $propertyName => $propertyValue) {
2323
$property = $info->addChild($name);
2424
$property->addChild('name', $propertyName);
25-
$property->addChild('value', $propertyValue);
25+
$property->addChild('value', htmlspecialchars($propertyValue));
2626
}
2727
continue;
2828
}
29-
$info->addChild($name, $value);
29+
$info->{$name} = $value;
3030
}
3131

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

Diff for: 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);

Diff for: src/Api/Operator/Webspace.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function create(array $properties, array $hostingProperties = null, strin
8383
foreach ($hostingProperties as $name => $value) {
8484
$property = $infoHosting->addChild('property');
8585
$property->addChild('name', $name);
86-
$property->addChild('value', $value);
86+
$property->addChild('value', htmlspecialchars($value));
8787
}
8888

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

Diff for: 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)