Skip to content

Commit

Permalink
Fixed bug: password node is empty if the passed password contains XML…
Browse files Browse the repository at this point in the history
… entities.
  • Loading branch information
struzik-vladislav committed Oct 2, 2024
1 parent 5422327 commit b924f06
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/Node/Contact/ContactPasswordNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public static function create(RequestInterface $request, \DOMElement $parentNode
throw new InvalidArgumentException('Invalid parameter "password".');
}

$node = $request->getDocument()->createElement('contact:pw', $password);
$node = $request->getDocument()->createElement('contact:pw');
$node->appendChild($request->getDocument()->createTextNode($password));
$parentNode->appendChild($node);

return $node;
Expand Down
3 changes: 2 additions & 1 deletion src/Node/Domain/DomainPasswordNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public static function create(RequestInterface $request, \DOMElement $parentNode
throw new InvalidArgumentException('Invalid parameter "password".');
}

$node = $request->getDocument()->createElement('domain:pw', $password);
$node = $request->getDocument()->createElement('domain:pw');
$node->appendChild($request->getDocument()->createTextNode($password));
$parentNode->appendChild($node);

if ($roid !== '') {
Expand Down
3 changes: 2 additions & 1 deletion src/Node/Session/NewPasswordNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public static function create(RequestInterface $request, \DOMElement $parentNode
throw new InvalidArgumentException('Invalid parameter "newPassword".');
}

$node = $request->getDocument()->createElement('newPW', $newPassword);
$node = $request->getDocument()->createElement('newPW');
$node->appendChild($request->getDocument()->createTextNode($newPassword));
$parentNode->appendChild($node);

return $node;
Expand Down
3 changes: 2 additions & 1 deletion src/Node/Session/PasswordNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public static function create(RequestInterface $request, \DOMElement $parentNode
throw new InvalidArgumentException('Invalid parameter "password".');
}

$node = $request->getDocument()->createElement('pw', $password);
$node = $request->getDocument()->createElement('pw');
$node->appendChild($request->getDocument()->createTextNode($password));
$parentNode->appendChild($node);

return $node;
Expand Down
4 changes: 2 additions & 2 deletions tests/Request/Contact/InfoContactRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testInfoWithPassword(): void
<contact:info xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
<contact:id>example-contact-id</contact:id>
<contact:authInfo>
<contact:pw>password</contact:pw>
<contact:pw>password &amp;&lt;&gt;'"</contact:pw>
</contact:authInfo>
</contact:info>
</info>
Expand All @@ -51,7 +51,7 @@ public function testInfoWithPassword(): void
EOF;
$request = new InfoContactRequest($this->eppClient);
$request->setIdentifier('example-contact-id');
$request->setPassword('password');
$request->setPassword('password &<>\'"');
$request->build();

$this->assertSame($expected, $request->getDocument()->saveXML());
Expand Down
4 changes: 2 additions & 2 deletions tests/Request/Domain/InfoDomainRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testInfoWithPassword(): void
<domain:info xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name hosts="all">example.com</domain:name>
<domain:authInfo>
<domain:pw>password</domain:pw>
<domain:pw>password &amp;&lt;&gt;'"</domain:pw>
</domain:authInfo>
</domain:info>
</info>
Expand All @@ -77,7 +77,7 @@ public function testInfoWithPassword(): void
$request = new InfoDomainRequest($this->eppClient);
$request->setDomain('example.com');
$request->setHosts(DomainNameNode::HOSTS_ALL);
$request->setPassword('password');
$request->setPassword('password &<>\'"');
$request->build();

$this->assertSame($expected, $request->getDocument()->saveXML());
Expand Down
12 changes: 6 additions & 6 deletions tests/Request/Session/LoginRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function testLogin(): void
<command>
<login>
<clID>login</clID>
<pw>password</pw>
<pw>password &amp;&lt;&gt;'"</pw>
<options>
<version>1.0</version>
<lang>en</lang>
Expand All @@ -33,7 +33,7 @@ public function testLogin(): void
EOF;
$request = new LoginRequest($this->eppClient);
$request->setLogin('login');
$request->setPassword('password');
$request->setPassword('password &<>\'"');
$request->setProtocolVersion('1.0');
$request->setLanguage('en');
$request->build();
Expand All @@ -49,8 +49,8 @@ public function testNewPassword(): void
<command>
<login>
<clID>login</clID>
<pw>password</pw>
<newPW>new-password</newPW>
<pw>password &amp;&lt;&gt;'"</pw>
<newPW>new-password &amp;&lt;&gt;'"</newPW>
<options>
<version>1.0</version>
<lang>en</lang>
Expand All @@ -68,8 +68,8 @@ public function testNewPassword(): void
EOF;
$request = new LoginRequest($this->eppClient);
$request->setLogin('login');
$request->setPassword('password');
$request->setNewPassword('new-password');
$request->setPassword('password &<>\'"');
$request->setNewPassword('new-password &<>\'"');
$request->setProtocolVersion('1.0');
$request->setLanguage('en');
$request->build();
Expand Down

0 comments on commit b924f06

Please sign in to comment.