Freshrss: URLs with an underscore "_" on the subdomains are considered invalid

Created on 29 Jul 2020  路  5Comments  路  Source: FreshRSS/FreshRSS

When trying to a add a new feed URL with an underscore on the subdomain there's the following error : URL https://url_underscore.example.com/feed.xml is invalid.

Here what's written to the logs : [warning] --- `` is not a valid URL.

(For a real life example, you can trigger that error with https://peertube_isolation.frama.io/list/feed.xml)

Version: 1.16.3-dev
PHP version: 7.3

Most helpful comment

Actually, I think we could / should add a little workaround to allow underscores anyway. As we are a "consumer", it is not our role to strictly check the validity of everything, as long as it does not break anything else, and is not too heavy.

All 5 comments

Interesting. As far as I know, _ are not allowed in hostnames, and so this behaviour seems correct.

https://www.ietf.org/rfc/rfc1123.txt
https://stackoverflow.com/questions/2180465/can-domain-name-subdomains-have-an-underscore-in-it

<?php
$url = 'https://url_underscore.example.com/feed.xml';

if (filter_var($url, FILTER_VALIDATE_URL)) {
    echo("$url is a valid URL");
} else {
    echo("$url is not a valid URL");
}
?>

Sure, _ aren't allowed in hostnames but there is a difference between a domain name and a hostname (as explained in the stackoverflow answers you linked).

The DNS itself places only one restriction on the particular labels that can be used to identify resource records. That one restriction relates to the length of the label and the full name.
https://tools.ietf.org/html/rfc2181#section-11

And

Characters that are allowed in a URI but do not have a reserved
purpose are called unreserved. These include uppercase and lowercase
letters, decimal digits, hyphen, period, underscore, and tilde.
https://tools.ietf.org/html/rfc3986#section-2.3

But then it's not an issue with FreshRSS but with PHP: https://bugs.php.net/bug.php?id=64948 (there is debate)

Actually, I think we could / should add a little workaround to allow underscores anyway. As we are a "consumer", it is not our role to strictly check the validity of everything, as long as it does not break anything else, and is not too heavy.

@treyssatvincent Could you please test https://github.com/FreshRSS/FreshRSS/pull/3133 ?

Tested and approved :+1:

Was this page helpful?
0 / 5 - 0 ratings