Skip to content

Common Issues

Trevor Rowbotham edited this page Jul 16, 2020 · 5 revisions

Schemes without trailing slashes in URIs

This affects common URL-like strings such as mailto:, javascript:, urn:, and others. For example:

new \Rowbot\URL\URL("myscheme:[email protected]/pathinfo/?query#frag");

The above code snippet will produce something like the following:

object(\Rowbot\URL\URL) {
    hash: "#frag"
    host: ""
    hostname: ""
    href: "myscheme:[email protected]"
    origin: "null"
    password: ""
    pathname: "[email protected]/pathinfo/"
    port: ""
    protocol: "myscheme:"
    search: "?query"
    searchParams: object(URLSearchParams)
    username: ""
}

Although the scheme, query, and fragment components were properly extracted, everything between the scheme and query components got dumped into the pathname attribute. This can be unexpected as, ideally, people would prefer username to be "foo", host and hostname to be "bar.com", and for pathname to only contain "/pathinfo/". This is a result of the way the url state machine handles schemes without the trailing slashes (e.g. https://).

The official position of the specification is that you will need to do additional post processing when working with these types of URL-like strings. Previous discussions on the issue can be found in whatwg/url#89, whatwg/url#125, whatwg/url#280, whatwg/url#331, whatwg/url#307, whatwg/url#385.

Excessively long domain names

Note - As of version 3.1.0, the intl extension is no longer used, and as a result domain names longer than 253 bytes will be parsed.

Valid domain names are limited to between 1 and 253 bytes, not including the root domain and its '.' delimiter. The URL specification, however, chooses to ignore this restriction when parsing URLs and will successfully parse a URL containing a domain name of arbitrary length. This implementation, however, is limited to the 253 byte restriction due to PHP Bug 72506.

IPv6 link-local addresses/IPv6 addresses with zone ids

The URL specification does not support link-local addresses. Please see this discussion for more context.

Minimum ICU version

Note - As of version 3.1.0, the intl extension is no longer used making the ICU version irrelevant.

This library depends on the intl extension. Behind the scenes, the intl extension relies on the ICU library. This library depends on features introduced in ICU version 4.6, making 4.6 the minimum required version. PHP versions prior to 7.4, however, can still be built with an ICU version as low as 4.0. Starting with PHP 7.4, the minimum ICU version that PHP can be built with will be raised to 50.1.

Finding the ICU version of your PHP installation

  1. If you have access to the PHP command-line, you could type php --ri intl, which would produce something like the following:

    intl
    
    Internationalization support => enabled
    version => 1.1.0
    ICU version => 57.1
    ICU Data version => 57.1
    
    Directive => Local Value => Master Value
    intl.default_locale => no value => no value
    intl.error_level => 0 => 0
    intl.use_exceptions => 0 => 0
  2. Alternatively, you could print out the INTL_ICU_VERSION constant:

    <?php
    echo INTL_ICU_VERSION; // This will print a string such as "4.2.1"
  3. Finally, you could also print out the information of your PHP installation using the phpinfo() function. You will need to scroll down and find the table labled "intl" and within that table, will be a row with the ICU version.

    <?php
    phpinfo();

What can I do if my version of ICU is less than 4.6?

You will need to contact your administrator, hosting provider, or other party that is responsible for the version of PHP that you are using and kindly ask them to use a version of PHP built with a more recent version of the ICU library. PHP 7.2+ SHOULD be using an ICU version of at least 4.6 due to the deprecation of the INTL_IDNA_VARIANT_2003 constant, but there is no hard requirement to do so.