- Issue created by @josephcheek
- Merge request !6294drupal-34165856: alter local.module to properly check whether a JS file is local or not. β (Open) created by josephcheek
- πΊπΈUnited States josephcheek Provo, UT
Locale.module incorrectly flags URLs with a colon (":") in their paths as external, throwing an Exception.
Code in locale.module tries to detect whether a file is local or not before attempting to extract strings from it. If it determines that the file is not local, it throws an exception. The problem is how it determines whether the file is local or not -- it checks for the presence of a colon (":") to determine whether it is local, assuming that any file path that contains a colon must be external. Colons are valid for HTML paths and also are allowed in files in both MacOS and Linux filesystems, though, so this test is inaccurate. Fortunately, UrlHelper::
already contains static methods to determine whether a URL is local or external.
In my case, I hit this exception when trying to attach a theme's library to a render array, as the library included a JS file with a colon in the path:
$ cat games_theme.libraries.yml
[snip]
cg:tng-game:
js:
js/cg:tng-game.js: {}
Note: Per RFC 3986 Section 3.3 (Path), a colon is a valid character for inclusion in paths.
Alter the code in locale.module to use UrlHelper::isExternal()
and !UrlHelper::externalIsLocal()
to properly determine whether the file should be read for string extraction.
https://git.drupalcode.org/project/drupal/-/merge_requests/6294
Write a unit test case for this, if needed.
None.
None.
None.
Locale.module incorrectly flags URLs with a colon (":") in their paths as external, throwing an Exception. Fixed.
Active
11.0 π₯