Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Thellimist/pi 1194 make unicode zones work by punycoding #148

Merged
merged 5 commits into from
Jun 28, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Cpanel/ClientActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use CF\API\Request;
use CF\Cpanel\Zone\Partial;
use CF\Integration\DefaultIntegration;
use TrueBV\Punycode;

class ClientActions
{
Expand Down Expand Up @@ -60,15 +61,21 @@ public function mergeCpanelAndCFDomains()
$cpanelDomainList = array_merge($cpanelDomainList, $getCpanelDomains['parked_domains']);
}

$Punycode = new Punycode();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new creates a hard coded dependency. Can we do getter/setter DI here and write a test to ensure this method handles unicode domains correctly?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we ran into this issue on wordpress as well is there a possibility of moving this fix into cloudflare-plugin-backend so we ensure we handle unicode domains correctly across all plugins?

Copy link
Contributor Author

@thellimist thellimist Jun 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is dependent on GET /zone?name=something.com endpoint. cloudflare-plugin-backend only has generic calls. Max we can do is move the getter/setter of Punycode library there but I think it'd be better if each plugin has it separately unless we moveGET /zone?name=something.com to cloudflare-plugin-backend


$mergedDomainList = array();
foreach ($cpanelDomainList as $cpanelDomain) {
$found = false;

$cpanelDomain = $Punycode->encode($cpanelDomain);

$request = new Request('GET', 'zones/', array('name' => $cpanelDomain), array());
$cpanelZone = $this->api->callAPI($request);

if ($this->api->responseOk($cpanelZone)) {
foreach ($cpanelZone['result'] as $cfZone) {
foreach ($cpanelZone['result'] as $cfZone) {
$cpanelDomain = $Punycode->decode($cpanelDomain);

if ($cfZone['name'] === $cpanelDomain) {
$found = true;
array_push($mergedDomainList, $cfZone);
Expand Down