Version 3.4.5
This commit is contained in:
1 parent
fb6b5baabc
commit
e4478369d8
1360 files changed
+228921
-179445
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
class Net_IDNA2_Exception extends Exception
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
require_once 'Net/IDNA2/Exception.php';
|
||||
|
||||
class Net_IDNA2_Exception_Nameprep extends Net_IDNA2_Exception
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
header( 'Content-Type: text/html; charset=UTF-8' );
|
||||
|
||||
require 'Net/IDNA.php';
|
||||
|
||||
|
||||
$idn = Net_IDNA::getInstance();
|
||||
|
||||
if (isset($_REQUEST['encode'])) {
|
||||
$decoded = isset($_REQUEST['decoded'])? $_REQUEST['decoded'] : '';
|
||||
|
||||
try {
|
||||
$encoded = $idn->encode($decoded);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
/* just swallow */
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['decode'])) {
|
||||
$encoded = isset($_REQUEST['encoded'])? $_REQUEST['encoded'] : '';
|
||||
|
||||
try {
|
||||
$decoded = $idn->decode($encoded);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
/* just swallow */
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($encoded)) {
|
||||
$encoded = '';
|
||||
}
|
||||
|
||||
if (!isset($decoded)) {
|
||||
$decoded = '';
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<title>Punycode Converter</title>
|
||||
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
body
|
||||
{
|
||||
font-family: Helvetica, Arial, sans-serif;
|
||||
font-size: 10pt;
|
||||
background: rgb( 255, 255, 255 );
|
||||
}
|
||||
|
||||
#centered
|
||||
{
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
#round
|
||||
{
|
||||
background-color: rgb( 240, 240, 240 );
|
||||
border: 1px solid black;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
#subhead
|
||||
{
|
||||
font-size: 8pt;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<table width="780" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td id="centered">
|
||||
<div id="round">
|
||||
<strong>IDNA Converter</strong><br />
|
||||
|
||||
<span id="subhead">
|
||||
See <a href="http://faqs.org/rfcs/rfc3490.html" title="IDNA" target="_blank">RFC3490</a>,
|
||||
<a href="http://faqs.org/rfcs/rfc3491.html" title="Nameprep, a Stringprep profile" target="_blank">RFC3491</a>,
|
||||
<a href="http://faqs.org/rfcs/rfc3492.html" title="Punycode" target="_blank">RFC3492</a> and
|
||||
<a href="http://faqs.org/rfcs/rfc3454.html" title="Stringprep" target="_blank">RFC3454</a><br />
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
This converter allows you to transfer domain names between the encoded (Punycode) notation and the
|
||||
decoded (UTF-8) notation.<br />
|
||||
|
||||
Just enter the domain name in the respective field and click on the button right beside it to have
|
||||
it converted. Please be aware, that you might even enter complete domain names (like jürgen-müller.de),
|
||||
but without the protocol (<strong>DO NOT</strong> enter http://müller.de) or an email address.<br />
|
||||
|
||||
Since the underlying library is still buggy, we cannot guarantee its usefulness and correctness. You should
|
||||
always doublecheck the results given here by converting them back to the original form.<br />
|
||||
|
||||
Any productive use is discouraged and prone to fail.<br />
|
||||
|
||||
<br />
|
||||
|
||||
Make sure, that your browser is capable of the <strong>UTF-8</strong> character encoding.<br />
|
||||
|
||||
<br />
|
||||
|
||||
<table border="0" cellpadding="2" cellspacing="2" align="center">
|
||||
<tr>
|
||||
<td class="thead" align="left">Original</td>
|
||||
<td class="thead" align="right">Punycode</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET">
|
||||
<input type="text" name="decoded" value="<?php echo $decoded; ?>" size="24" maxlength="255" />
|
||||
<input type="submit" name="encode" value="Encode >>" />
|
||||
</form>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET">
|
||||
<input type="submit" name="decode" value="<< Decode" />
|
||||
<input type="text" name="encoded" value="<?php echo $encoded; ?>" size="24" maxlength="255" />
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
if (!defined('PHPUnit2_MAIN_METHOD')) {
|
||||
define('PHPUnit2_MAIN_METHOD', 'Net_IDNA2_AllTests::main');
|
||||
}
|
||||
|
||||
require_once 'PHPUnit2/TextUI/TestRunner.php';
|
||||
|
||||
require_once 'Net_IDNA2Test.php';
|
||||
require_once 'draft-josefsson-idn-test-vectors.php';
|
||||
|
||||
class Net_IDNA2_AllTests
|
||||
{
|
||||
public static function main()
|
||||
{
|
||||
PHPUnit2_TextUI_TestRunner::run(self::suite());
|
||||
}
|
||||
|
||||
public static function suite()
|
||||
{
|
||||
$suite = new PHPUnit2_Framework_TestSuite('PEAR - Net_IDNA2');
|
||||
|
||||
$suite->addTestSuite('Net_IDNA2Test');
|
||||
$suite->addTestSuite('draft-josefsson-idn-test-vectors');
|
||||
|
||||
return $suite;
|
||||
}
|
||||
}
|
||||
|
||||
if (PHPUnit2_MAIN_METHOD == 'Net_IDNA2_AllTests::main') {
|
||||
Net_IDNA2_AllTests::main();
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
require_once 'Net/IDNA2.php';
|
||||
require_once 'PHPUnit2/Framework/TestCase.php';
|
||||
|
||||
class Net_IDNA2Test extends PHPUnit2_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Initialise tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->idn = new Net_IDNA2();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a complete URL consisting also of port-number etc. will be decoded just fine, test 1
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testShouldDecodePortNumbersFragmentsAndUrisCorrectly1()
|
||||
{
|
||||
$result = $this->idn->decode('http://www.xn--ml-6kctd8d6a.org:8080/test.php?arg1=1&arg2=2#fragment');
|
||||
$this->assertSame("http://www.\xD0\xB5\xD1\x85\xD0\xB0m\xD1\x80l\xD0\xB5.org:8080/test.php?arg1=1&arg2=2#fragment", $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a complete URL consisting also of port-number etc. will be decoded just fine, test 2
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testShouldDecodePortNumbersFragmentsAndUrisCorrectly2()
|
||||
{
|
||||
$result = $this->idn->decode('http://xn--tst-qla.example.com:8080/test.php?arg1=1&arg2=2#fragment');
|
||||
$this->assertSame("http://täst.example.com:8080/test.php?arg1=1&arg2=2#fragment", $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test encoding of German letter Eszett according to the original standard (IDNA2003)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEncodingForGermanEszettUsingIDNA2003()
|
||||
{
|
||||
// make sure to use 2003-encoding
|
||||
$this->idn->setParams('version', '2003');
|
||||
$result = $this->idn->encode('http://www.straße.example.com/');
|
||||
|
||||
$this->assertSame("http://www.strasse.example.com/", $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test encoding of German letter Eszett according to the "new" standard (IDNA2005/IDNAbis)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEncodingForGermanEszettUsingIDNA2008()
|
||||
{
|
||||
// make sure to use 2008-encoding
|
||||
$this->idn->setParams('version', '2008');
|
||||
$result = $this->idn->encode('http://www.straße.example.com/');
|
||||
// switch back for other testcases
|
||||
$this->idn->setParams('version', '2003');
|
||||
|
||||
$this->assertSame("http://www.xn--strae-oqa.example.com/", $result);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user