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

Replace idna_convert.class.php with Algo26\IdnaConvert, allow custom idna library #776

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 44 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -32,7 +32,7 @@ jobs:
tools: none

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
- name: "Install Composer dependencies (PHP < 8.3)"
if: ${{ matrix.php < '8.3' }}
uses: "ramsey/composer-install@v2"
Expand All @@ -46,6 +46,48 @@ jobs:
- name: Run unit tests
run: composer test

test-with-libraries:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php: ['8.2']
with: ['idna-convert-v3']
include:
- php: '7.2'
with: 'idna-convert-v2'

name: "PHP: ${{ matrix.php }}"

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install PHP with latest composer
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: error_reporting=-1, display_errors=On, log_errors_max_len=0
coverage: none
tools: none

- name: "Install idna-convert v3"
if: ${{ matrix.with = 'idna-convert-v3' }}
run: "composer require --dev algo26-matthias/idna-convert:^3"

- name: "Install idna-convert v2"
if: ${{ matrix.with = 'idna-convert-v2' }}
run: "composer require --dev algo26-matthias/idna-convert:^2"

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
- name: "Install Composer dependencies"
uses: "ramsey/composer-install@v2"

- name: Run unit tests
run: composer test

test-compiled:
runs-on: ubuntu-latest

Expand All @@ -62,7 +104,7 @@ jobs:
tools: none

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
- name: "Install Composer dependencies"
uses: "ramsey/composer-install@v2"
with:
Expand Down
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -39,6 +39,7 @@
"ext-iconv": "",
"ext-intl": "",
"ext-mbstring": "",
"algo26-matthias/idna-convert": "IdnaConvert allows you to convert internationalized domain names",
"mf2/mf2": "Microformat module that allows for parsing HTML for microformats"
},
"autoload": {
Expand Down
84 changes: 84 additions & 0 deletions tests/Integration/IdnaSupportTest.php
@@ -0,0 +1,84 @@
<?php

declare(strict_types=1);
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2022 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/

namespace SimplePie\Tests\Integration;

use Algo26\IdnaConvert\IdnaConvert;
use Algo26\IdnaConvert\ToUnicode;
use PHPUnit\Framework\TestCase;

class IdnaSupportTest extends TestCase
Art4 marked this conversation as resolved.
Show resolved Hide resolved
{
/**
* @dataProvider getIdnaData
*/
public function test_idna_support(string $encoded, string $expected): void
{
if (class_exists(ToUnicode::class)) {
// Support for algo26-matthias/idna-convert:^3
$idnaConvert = new ToUnicode();

$this->assertSame($expected, $idnaConvert->convert($encoded));
} else if (class_exists(IdnaConvert::class)) {
// Support for algo26-matthias/idna-convert:^2
$idnaConvert = new IdnaConvert();

$this->assertSame($expected, $idnaConvert->encode($encoded));
} else {
$this->assertSame($encoded, $encoded);
}
}

public function getIdnaData(): array
{
return [
['', ''],
['xn--mller-kva', 'müller'],
['xn--weienbach-i1a', 'weißenbach'],
['xn----9mcj9fole', 'يوم-جيد'],
['xn----2hckbod3a', 'יום-טוב'],
];
}
}