The locale module defines a hook_url_outbound_alter that gets called when url() is called. This hook will call the function locale_language_url_rewrite_url in locale.inc when the language negotiation is based on URL (path prefix or domain).
This function sets the prefix option to the language prefix, causing url() to prefix it to the URL passed in (if it is a local URL). However, when a URL is passed in to a resource that actually exists on the server (e.g. images, js, css) this prefix also gets added leading to an incorrect URL being returned.
The error will not reveal itself very often, as most URL's pointing to images and such will not go through url(). An exception is the pathologic filter that does not know if a link it is altering is a link to a Drupal path or to an existing resource and thus always passes the link through url().
I'm not sure who's error this is: url() (i.e. common.inc), locale or pathologic ("url() is only meant for internal Drupal paths"). I filed it under locale, but while typing this, I am starting to doubt and am more thinking towards the component "base system".
Comments
Comment #1
fietserwinAnyone having a thought on this?
I will give an example to clarify what is going on:
I think this is an error of the locale module, more specifically the URL language negotiation plugin. IMO it should not add a prefix to existing resources, though it should change domain in these cases.
Comment #2
idflood CreditAttribution: idflood commentedI think you are right, the "locale_language_url_rewrite_url function should not prepend a language prefix if the url point to an existing ressource.
For reference these issues are possibly related to this:
#348421: Multilingual links with Pathologic
#1431146: Bad urls generated (maybe related to i18n and core 7.12)
#698880: path to images (load anim gif) corrupted when module locale is enabled
#1370402: Libraries not loaded when using i18n module
Comment #11
catchURL generation has completely changed in 8.x/9.x and we don't do rewriting on internal/asset paths, moving back to 7.x