Skip to content

Commit

Permalink
Use idn_to_ascii function instead of idna_convert library
Browse files Browse the repository at this point in the history
The `idna_convert` library is outdated and there is now a native PHP function to convert IDNs to Punycode.
It requires `intl` extension or a [polyfill](https://github.com/symfony/polyfill-intl-idn).

`compress_parse_url` will append `?` and `#` to the URI even if there is no query string or hash fragment, and insert `//` even when there is no authority part. To avoid this and the breakage of tests this would cause, let’s call the function only for files having a non-empty authority part of the URI (i.e. non-local files) that contains characters that are not considered printable ASCII (such as bytes of UTF-8 encoded Unicode characters).

In the future, we might leave the IDN support to HTTP library to deal with.
  • Loading branch information
jtojnar committed Feb 16, 2023
1 parent 7b0901c commit a9f41f1
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 1,608 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- PHP 7.2 or newer is now required by @Art4 in [#743](https://github.com/simplepie/simplepie/pull/743)
- Parse\Date: Clean up regex structure by @jtojnar in [#765](https://github.com/simplepie/simplepie/pull/765)
- Declare strict_types=1 in every file by @Art4 in [#763](https://github.com/simplepie/simplepie/pull/763)
- Use `idn_to_ascii` function instead of `idna_convert` library (requires `intl` extension or a [polyfill](https://github.com/symfony/polyfill-intl-idn)) by @jtojnar in [#785](https://github.com/simplepie/simplepie/pull/785)

### Fixed

Expand Down
7 changes: 3 additions & 4 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Requirements
* PHP 7.2+ (Required since SimplePie 1.8.0)
* libxml2 (certain 2.7.x releases are too buggy for words, and will crash)
* One of iconv, mbstring or intl extensions
* intl extension or [symfony/polyfill-intl-idn](https://github.com/symfony/polyfill-intl-idn) to support IDNs
* cURL or fsockopen()
* PCRE support

Expand All @@ -29,10 +30,8 @@ What comes in the package?
server for required settings.
6. `demo/` - A basic feed reader demo that shows off some of SimplePie's more
noticeable features.
7. `idn/` - A third-party library that SimplePie can optionally use to
understand Internationalized Domain Names (IDNs).
8. `build/` - Scripts related to generating pieces of SimplePie
9. `test/` - SimplePie's unit test suite.
7. `build/` - Scripts related to generating pieces of SimplePie
8. `test/` - SimplePie's unit test suite.

### Where's `simplepie.inc`?
Since SimplePie 1.3, we've split the classes into separate files to make it easier
Expand Down
1 change: 0 additions & 1 deletion demo/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Include SimplePie
// Located in the parent directory
include_once('../autoloader.php');
include_once('../idn/idna_convert.class.php');

// Create a new instance of the SimplePie object
$feed = new \SimplePie\SimplePie();
Expand Down
1 change: 0 additions & 1 deletion demo/test.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
include_once('../autoloader.php');
include_once('../idn/idna_convert.class.php');

// Parse it
$feed = new \SimplePie\SimplePie();
Expand Down
502 changes: 0 additions & 502 deletions idn/LICENCE

This file was deleted.

123 changes: 0 additions & 123 deletions idn/ReadMe.txt

This file was deleted.

0 comments on commit a9f41f1

Please sign in to comment.