Commit fdf78c59 authored by Michael Herold's avatar Michael Herold
Browse files

Adds IDN suport (closes #19)

parent 68c83067
......@@ -2,6 +2,8 @@ v0.6.0-unreleased
- Fixes missing unicode support for requests.
- Adds config fields 'site_information_url' and 'footer'
- [dns] Adds support for NS, SSHFP and TXT resource records
- [dns] Adds support for entering IDNs as UTF-8
- [dns] IDNs are displayed as UTF-8 if bijection exists
- [login_http] Adds support for login via email address as user account
v0.5.0
- Fixes missing generation of global gettext .mo-files.
......
......@@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: edentata\n"
"POT-Creation-Date: 2015-11-07 17:01+0100\n"
"PO-Revision-Date: 2015-11-07 17:02+0100\n"
"PO-Revision-Date: 2016-01-06 15:08+0100\n"
"Last-Translator: Michael Herold <quabla@hemio.de>\n"
"Language-Team: \n"
"Language: de_DE\n"
......@@ -70,7 +70,7 @@ msgstr ""
#: src/class/Utils.php:54
msgid "IDNA_ERROR_DISALLOWED"
msgstr "The domain contains disallowed characters."
msgstr "Die Domain enthält verbotene Zeichen."
#: src/class/Utils.php:57
msgid "IDNA_ERROR_PUNYCODE"
......
msgid ""
msgstr ""
"Project-Id-Version: edentata\n"
"POT-Creation-Date: 2016-01-06 15:06+0100\n"
"PO-Revision-Date: 2016-01-06 15:06+0100\n"
"Last-Translator: Michael Herold <quabla@hemio.de>\n"
"Language-Team: \n"
"Language: en_US\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.6.10\n"
"X-Poedit-Basepath: ../../..\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-SearchPath-0: src/class\n"
"X-Poedit-SearchPath-1: src/load\n"
#: src/class/Config.php:63
#, php-format
msgid "Unknown setting \"%s\""
msgstr ""
#: src/class/ContentNav.php:58
msgid "Services"
msgstr ""
#: src/class/LoadModule.php:88
#, php-format
msgid "Failed to load module \"%s\". The module id is invalid."
msgstr ""
#: src/class/LoadModule.php:99
#, php-format
msgid "Failed to load module \"%s\". Module not found."
msgstr ""
#: src/class/Request.php:103
#, php-format
msgid "Invalid input with key \"%s\"."
msgstr ""
#: src/class/Utils.php:33
msgid "IDNA_ERROR_EMPTY_LABEL"
msgstr ""
#: src/class/Utils.php:36
msgid "IDNA_ERROR_LABEL_TOO_LONG"
msgstr ""
#: src/class/Utils.php:39
msgid "IDNA_ERROR_DOMAIN_NAME_TOO_LONG"
msgstr ""
#: src/class/Utils.php:42
msgid "IDNA_ERROR_LEADING_HYPHEN"
msgstr ""
#: src/class/Utils.php:45
msgid "IDNA_ERROR_TRAILING_HYPHEN"
msgstr ""
#: src/class/Utils.php:48
msgid "IDNA_ERROR_HYPHEN_3_4"
msgstr ""
#: src/class/Utils.php:51
msgid "IDNA_ERROR_LEADING_COMBINING_MARK"
msgstr ""
#: src/class/Utils.php:54
msgid "IDNA_ERROR_DISALLOWED"
msgstr "The domain contains disallowed characters."
#: src/class/Utils.php:57
msgid "IDNA_ERROR_PUNYCODE"
msgstr ""
#: src/class/Utils.php:60
msgid "IDNA_ERROR_LABEL_HAS_DOT"
msgstr ""
#: src/class/Utils.php:63
msgid "IDNA_ERROR_INVALID_ACE_LABEL"
msgstr ""
#: src/class/Utils.php:66
msgid "IDNA_ERROR_BIDI"
msgstr ""
#: src/class/Utils.php:69
msgid "IDNA_ERROR_CONTEXTJ"
msgstr ""
#: src/class/Utils.php:72
msgid "Unkown IDNA Error"
msgstr ""
#: src/class/Window.php:116
msgid "Permit Deletion"
msgstr ""
#: src/class/Window.php:124
msgid "You must activate the switch before you can submit"
msgstr ""
#: src/class/Window.php:129
msgid "Cancel"
msgstr ""
#: src/class/checks/Password.php:43
#, php-format
msgid "The chosen password is too weak: %s."
msgstr ""
#: src/class/exception/Error.php:30 src/class/gui/StatusList.php:46
msgid "Error"
msgstr ""
#: src/class/exception/Successful.php:30
msgid "Successful"
msgstr ""
#: src/class/exception/UnknownOperation.php:30
#, php-format
msgid "Unkown module action \"%s\"."
msgstr ""
#: src/class/exception/Warning.php:30 src/class/gui/StatusList.php:47
msgid "Warning"
msgstr ""
#: src/class/gui/FieldEmailWithSelect.php:54
msgid "Local Part"
msgstr ""
#: src/class/gui/FieldEmailWithSelect.php:57
msgid "Domain"
msgstr ""
#: src/class/gui/FieldNewPassword.php:39
msgid "New Password"
msgstr ""
#: src/class/gui/FieldNewPassword.php:41
msgid "Repeat Password"
msgstr ""
#: src/class/gui/FieldNewPassword.php:55
msgid "The repeated password does not match the original one."
msgstr ""
#: src/class/gui/Message.php:55 src/class/gui/StatusList.php:45
msgid "OK"
msgstr ""
#: src/class/gui/OutputStatus.php:34
msgid "Status"
msgstr ""
#: src/class/gui/Progress.php:55
#, php-format
msgid ""
"There are elements in this view with status %s. These tasks should be "
"processed by the system soon. If the status remains unchanged please contact "
"the support. This view will NOT be refreshed automatically."
msgstr ""
#: src/class/gui/Progress.php:65
msgid "Refresh View"
msgstr ""
#: src/class/gui/Progress.php:84
msgid "Deletion Pending"
msgstr ""
#: src/class/gui/Progress.php:88
msgid "Changes Pending"
msgstr ""
#: src/class/gui/Progress.php:92
msgid "Setup Pending"
msgstr ""
#: src/class/gui/Progress.php:96
msgid "Deleted"
msgstr ""
#: src/class/gui/Progress.php:100
msgid "Unknown Status"
msgstr ""
#: src/class/gui/WindowModule.php:44
msgid "Overview"
msgstr ""
#: src/class/sql/ExceptionMapping.php:42
msgid "Invalid unser login."
msgstr ""
#: src/class/sql/ExceptionMapping.php:52
msgid ""
"The operation you want to perform would exceed your current contingent. "
"Please contact the support to extend your contingent."
msgstr ""
#: src/class/sql/ExceptionMapping.php:60
msgid "The object you tried to change is inaccessible or missing."
msgstr ""
#: src/load/main.php:40 src/load/main.php:69
#, php-format
msgid ""
"An error has occured. We are sorry. You should contact the support and "
"reference to error id \"%s\". You can use the back button of your browser "
"and try again."
msgstr ""
#: src/load/main.php:143
msgid "Logout successfull"
msgstr ""
#: src/load/main.php:155 src/load/main.php:176
msgid "Login failed"
msgstr ""
#: src/load/main.php:184
msgid "User"
msgstr ""
#: src/load/main.php:189
msgid "User Settings"
msgstr ""
#: src/load/main.php:203
msgid "Stop acting as deputy"
msgstr ""
#: src/load/main.php:213
msgid "Act as Deputy"
msgstr ""
#: src/load/main.php:223
msgid "Support"
msgstr ""
#: src/load/main.php:229
msgid "Logout"
msgstr ""
#: src/load/main.php:250 src/load/main.php:252
msgid "Settings"
msgstr ""
#: src/load/main.php:276
msgid "Tried to access unknown or disabled module"
msgstr ""
#: src/load/main.php:305
msgid "Site Information"
msgstr ""
......@@ -76,13 +76,27 @@ class Utils
public static function idnToAscii($domain)
{
$idnaInfo = [];
$utf8 = idn_to_ascii($domain
$ascii = idn_to_ascii($domain
,
IDNA_CHECK_BIDI | IDNA_CHECK_CONTEXTJ | IDNA_NONTRANSITIONAL_TO_ASCII
| IDNA_DEFAULT
, INTL_IDNA_VARIANT_UTS46, $idnaInfo);
if ($ascii === false)
throw new exception\Error(self::getIdnaErrorMessage($idnaInfo['errors']),
$idnaInfo['errors']);
return $ascii;
}
public static function idnToUtf8($domain)
{
$idnaInfo = [];
$utf8 = idn_to_utf8($domain,
IDNA_CHECK_BIDI | IDNA_CHECK_CONTEXTJ | IDNA_NONTRANSITIONAL_TO_UNICODE,
INTL_IDNA_VARIANT_UTS46, $idnaInfo);
if ($utf8 === false)
throw new exception\Error(self::getIdnaErrorMessage($idnaInfo['errors']),
$idnaInfo['errors']);
......@@ -90,6 +104,22 @@ class Utils
return $utf8;
}
public static function idnKeepUtf8Bijection($domain)
{
if (self::idnToUtf8(self::idnToAscii($domain)) === $domain)
return $domain;
else
return self::idnToAscii($domain);
}
public static function idnToUtf8Bijection($domain)
{
if (self::idnToAscii(self::idnToUtf8($domain)) === $domain)
return self::idnToUtf8($domain);
else
return $domain;
}
public static function getPost()
{
$input = file_get_contents('php://input');
......
......@@ -22,6 +22,7 @@ use hemio\edentata\gui;
use hemio\form;
use hemio\html;
use hemio\edentata\exception;
use hemio\edentata\Utils;
/**
* Description of CustomCreate
......@@ -171,8 +172,13 @@ class CustomCreate extends Window
if ($form->correctSubmitted()) {
$rdata = self::getRdata($type, $form);
$params = ['p_registered' => $domain, 'p_type' => $type, 'p_rdata' => $rdata]
+ $form->getVal(['domain', 'ttl']);
$params = [
'p_registered' => Utils::idnToAscii($domain)
, 'p_type' => $type
, 'p_rdata' => $rdata
] + $form->getVal(['domain', 'ttl']);
$params['p_domain'] = Utils::idnToAscii($params['p_domain']);
if (!$params['p_ttl'])
$params['p_ttl'] = null;
......
......@@ -21,6 +21,7 @@ namespace hemio\edentata\module\dns;
use hemio\form;
use hemio\edentata\gui;
use hemio\edentata\exception;
use hemio\edentata\Utils;
/**
* Description of CustomDetails
......@@ -57,7 +58,8 @@ class CustomDetails extends Window
$x = (new CustomCreate($this->module))->formType($domain, $data['type']);
$name = new gui\Output(_('Name (Domain)'), $data['domain']);
$name = new gui\Output(_('Name (Domain)'),
Utils::idnToUtf8Bijection($data['domain']));
$window->getForm()->addChild($name);
$type = new gui\Output(_('Type'), $data['type']);
......
......@@ -20,6 +20,7 @@ namespace hemio\edentata\module\dns;
use hemio\edentata\gui;
use hemio\html;
use hemio\edentata\Utils;
/**
* Description of Overview
......@@ -59,17 +60,19 @@ class Overview extends Window
$list = new gui\Listbox();
foreach ($this->db->registeredSelect() as $domain) {
$idn = Utils::idnToUtf8Bijection($domain['domain']);
$unmanaged = $domain['subservice'] == 'unmanaged' ?
' ['._('unmanged').']' : '';
$list->addLinkEntry(
$this->request->derive(
'registered_details'
, $domain['domain']
, $idn
)
,
new \hemio\html\Str(
sprintf('%s (%s)%s', $domain['domain'],
$domain['public_suffix'], $unmanaged))
sprintf('%s (%s)%s', $idn,
Utils::idnToUtf8Bijection($domain['public_suffix']),
$unmanaged))
, $domain['backend_status']
);
}
......
......@@ -21,6 +21,7 @@ namespace hemio\edentata\module\dns;
use hemio\edentata\gui;
use hemio\form;
use hemio\html;
use hemio\edentata\Utils;
/**
* Description of RegisteredDetails
......@@ -73,8 +74,8 @@ class RegisteredDetails extends Window
{
$fieldset = new gui\Fieldset(_('Domain Details'));
$dataRegist = $this->db->resellerRegisteredSelectSingle($registered)->fetch();
$dataDomain = $this->db->registeredSelectSingle($registered)->fetch();
$dataRegist = $this->db->resellerRegisteredSelectSingle(Utils::idnToAscii($registered))->fetch();
$dataDomain = $this->db->registeredSelectSingle(Utils::idnToAscii($registered))->fetch();
if ($dataDomain['subservice'] == 'unmanaged') {
$fieldset->addChild(
......@@ -133,8 +134,9 @@ class RegisteredDetails extends Window
$fieldset = new gui\Fieldset(_('Domain Service Activation'));
$list = new gui\Listbox();
foreach ($this->db->serviceDomainSelect($registered) as $domain) {
foreach ($this->db->serviceDomainSelect(Utils::idnToAscii($registered)) as $domain) {
$dom = $domain['domain'];
$domUtf8 = Utils::idnToUtf8Bijection($dom);
$container = new form\Container;
$container->addChild(new html\Str($dom));
......@@ -156,7 +158,7 @@ class RegisteredDetails extends Window
$this->request->derive(
'service_details'
, $registered
, $dom
, $domUtf8
)
, $container
);
......@@ -172,14 +174,14 @@ class RegisteredDetails extends Window
protected function custom($registered)
{
$service = $this->db->customSelect($registered)->fetchAll();
$service = $this->db->customSelect(Utils::idnToAscii($registered))->fetchAll();
if (empty($service))
return new html\Nothing;
$list = new gui\Listbox();
foreach ($service as $record) {
$domain = $record['domain'];
$domain = Utils::idnToUtf8Bijection($record['domain']);
$span = new html\Span;
$ul = new html\Ul();
......
......@@ -20,6 +20,7 @@ namespace hemio\edentata\module\dns;
use hemio\edentata\gui;
use hemio\form;
use hemio\edentata\Utils;
/**
* Description of ServiceDetails
......@@ -31,30 +32,15 @@ class ServiceDetails extends Window
public function content($registered, $domain)
{
$domainAscii = Utils::idnToAscii($domain);
$domainReadable = Utils::idnKeepUtf8Bijection($domain);
$window = $this->newFormWindow('service_details',
_('Service Activation'), $domain,
_('Service Activation'), $domainReadable,
_('Save'));
var_dump($domain);
\hemio\edentata\Utils::idnToAscii($domain);
$idnaInfo = [];
$x = idn_to_ascii($domain,
IDNA_CHECK_BIDI | IDNA_CHECK_CONTEXTJ | IDNA_NONTRANSITIONAL_TO_ASCII
| IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46, $idnaInfo);
var_dump($x);
var_dump($idnaInfo);
$idnaInfo = [];
$x = idn_to_utf8($x,
IDNA_CHECK_BIDI | IDNA_CHECK_CONTEXTJ | IDNA_NONTRANSITIONAL_TO_UNICODE,
INTL_IDNA_VARIANT_UTS46, $idnaInfo);
var_dump($x);
var_dump($idnaInfo);
$activeServices = [];
$dnsService = $this->db->serviceSelect($domain)->fetchAll();
$dnsService = $this->db->serviceSelect($domainAscii)->fetchAll();
foreach ($dnsService as $service) {
$activeServices[$service['service']] = $service['service_entity_name'];
}
......@@ -98,7 +84,7 @@ class ServiceDetails extends Window
}
$this->handleSubmit($window->getForm(), $insServices, $delServices,
$registered, $domain);
$registered, $domainAscii);
return $window;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment