Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

domains with idna localpart and "normal" tld can't be encoded #2

Closed
herndlm opened this issue Jan 21, 2016 · 5 comments
Closed

domains with idna localpart and "normal" tld can't be encoded #2

herndlm opened this issue Jan 21, 2016 · 5 comments
Labels

Comments

@herndlm
Copy link

herndlm commented Jan 21, 2016

<?php

require_once(__DIR__ . '/IdnaConvert.php');
use Mso\IdnaConvert\IdnaConvert;

$IDN = new IdnaConvert();
$output = $IDN->encode('knörz.info');
error_log($output);
$output2 = $IDN->decode($output);
error_log($output2);

results in

$ php test.php
xn--knrz-6qa.info
PHP Fatal error:  Uncaught exception 'InvalidArgumentException' with message 'This is not a punycode string' in <dir>/IdnaConvert.php:431
Stack trace:
#0 <dir>/IdnaConvert.php(279): Mso\IdnaConvert\IdnaConvert->_decode('info')
#1 <dir>/test.php(9): Mso\IdnaConvert\IdnaConvert->decode('xn--knrz-6qa.in...')
#2 {main}
  thrown in <dir>/IdnaConvert.php on line 431

because "_decode" also tries to decode the "info" which is not punycode. If I try it with "knörz.knörz" it works. Is this a bug or am I doing something else wrong?

php infos:

$ php --version
PHP 5.4.39 (cli) (built: Mar 19 2015 06:59:35) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
    with Suhosin v0.9.37.1, Copyright (c) 2007-2014, by SektionEins GmbH

update: btw. it works with version 0.9.0

@ghost
Copy link

ghost commented Jan 21, 2016

Could you please check, whether it works with the dev branch? Thx in advance!

@ghost ghost added the bug label Jan 21, 2016
@ghost ghost self-assigned this Jan 21, 2016
@herndlm
Copy link
Author

herndlm commented Jan 21, 2016

Well, I got a bunch of Class x not found errors (maybe I'm using the namespaces wrong) and after fiddling around with includes I got

PHP Parse error:  syntax error, unexpected '+', expecting ',' or ';' in <dir>src/Punycode.php on line x

but fixing this gets me something like

PHP Catchable fatal error:  Argument 1 passed to Mso\IdnaConvert\Punycode::__construct() must be an instance of Mso\IdnaConvert\NamePrepDataInterface, null given, called in <dir>/src/IdnaConvert.php on line x and defined in <dir>/src/Punycode.php on line y

@ghost
Copy link

ghost commented Jan 21, 2016

Alright, thanks for trying. I'll look into the whole issue in the next few days and will get back to you as soon as possible.

Stick with 0.9 for the time being.

@ghost
Copy link

ghost commented Jan 24, 2016

Hi,

first of all please update your PHP to at least version 5.6.x. A few language constructs used are not available to your old PHP version.
If this is not possible, you are unfortunately stuck with version 0.9.x of IdnaConvert.

I looked into the issues and fixed the apparent problems with instantiating the PunyCode class (alongside some minor other issues).

Hope that helps.

@herndlm
Copy link
Author

herndlm commented Jan 25, 2016

We can't update our PHP atm, but are working on it. Thx for your help. I'll close this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant