dev/drupal#85 Drupal8: Fix bug with empty language prefix mangling https:// to http:/ #15912
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
On a Drupal 8 multilingual site, if you are using URL "Path prefix" language negotiation, and set one of the prefixes to empty (so, for that language, there is no prefix), then CiviCRM resource URLs will get mangled to be "https:/" (one slash) instead of "https://" (two slashes)
Here's what the config would look like:
Before
On CiviCRM pages, it's trying to load CSS and JS from URLs like "https:/example.org" (one slash) rather than "https://example.org" (two slashes)
After
The right URL gets used!
Technical Details
The problem is in
CRM_Utils_System_Drupal8::languageNegotiationURL()
:If
$config['prefixes'][$language]
is an empty string, then we end up withstr_replace("//", "/", $url)
which is taking the double slash in "https://" and turning it into "https:/"