• I use a remote server for images
  • Logo and favicon location must be URL
  • Site(s) support both HTTP and HTTPS

As a consequence I must be able to input an URL of the form...
//my.remote.host/path (what is perfectly valid)
... and get it accepted, which is not the case.

Since I'm not going to wait half a decade hoping for the patch to be rerolled every 6 month before a very hypotetical merge, I just upload it here for public storage purpose.
Don't expect other input from me on issue, I already patched my instance.

Comments

drzraf created an issue. See original summary.

makbul_khan8’s picture

Assigned: Unassigned » makbul_khan8
makbul_khan8’s picture

Assigned: makbul_khan8 » Unassigned

Hi Dupalers,

Please let me know if this could be a valid issue, if yes I have my code ready and will post a patch ASAP.

Thanks in advance!!

fabianx’s picture

Status: Active » Needs work

The bug report is valid.

I would agree that it would be good to support schema-less urls.

I think we should check that if the url starts with '//' that adding 'http:' makes it valid, e.g. is_file() does return TRUE then.

So the patch needs some work, but can be committed fairly quick then I think.

Oh and please check on http://simplytest.me if this is an issue for Drupal 8 as well.

Unfortunately per our backport policy it would need to be fixed there first - if that was the case.

And thank you for your continued contributions!

makbul_khan8’s picture

Assigned: Unassigned » makbul_khan8
aerozeppelin’s picture

Status: Needs work » Needs review
StatusFileSize
new1.52 KB
new1.52 KB
new2.91 KB

Patch for D8.

The last submitted patch, 6: test-only-fail-2687045-6.patch, failed testing.

fabianx’s picture

Version: 7.x-dev » 8.3.x-dev
Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs backport to D7

RTBC for D8

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/system/src/Form/ThemeSettingsForm.php
@@ -464,11 +465,20 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
+    // Scheme-independant URL (dual HTTP/HTTPS) are valid.
+    if (strncmp($path, "//", 2) == 0) {
+      $http_path = 'http:' . $path;
+      $file_headers = @get_headers($http_path);
+      if (UrlHelper::isValid($http_path) && strstr($file_headers[0], '404') === FALSE && $file_headers != FALSE) {
+        return $path;
+      }
+    }

Imho this should come after the absolute local path check. Also it should just use is_file() like other checks in the function instead of get_headers()

aerozeppelin’s picture

Status: Needs work » Needs review
StatusFileSize
new1.31 KB
new3.02 KB

Updates as per #9.

fabianx’s picture

Status: Needs review » Reviewed & tested by the community

I think it is RTBC - except for two nits.

  1. +++ b/core/modules/system/src/Form/ThemeSettingsForm.php
    @@ -473,6 +475,15 @@ protected function validatePath($path) {
    +      if (UrlHelper::isValid($http_path) && is_file(substr($file_path, 1, strlen($file_path)))) {
    

    nit - IIRC, substr() can just take 2 arguments as well.

    e.g.

    is_file(substr($path, 1));

    should be equivalent.

  2. +++ b/core/modules/system/src/Tests/System/ThemeTest.php
    @@ -82,6 +82,11 @@ function testThemeSettings() {
    +      substr($base_url, strpos($base_url, '//')) . '/' . $default_theme_path . '/logo.svg' => [
    +        'form' => substr($base_url, strpos($base_url, '//')) . '/' . $default_theme_path . '/logo.svg',
    +        'src' => substr($base_url, strpos($base_url, '//')) . '/' . $default_theme_path . '/logo.svg',
    +      ],
    

    IIRC correctly base_url is deprecated, but unsure right now.

aerozeppelin’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new661 bytes
new3 KB

Updates as per #11.

fabianx’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC, thanks!

The last submitted patch, allow-scheme-agnostic-url-for-logo.patch, failed testing.

dawehner’s picture

+++ b/core/modules/system/src/Form/ThemeSettingsForm.php
@@ -473,6 +475,15 @@ protected function validatePath($path) {
+    // Scheme-independant URL (dual HTTP/HTTPS) are valid.
+    if (strncmp($path, "//", 2) == 0) {
+      $http_path = 'http:' . $path;
+      $parsed_url = parse_url($http_path);
+      $file_path = $parsed_url['path'];
+      if (UrlHelper::isValid($http_path) && is_file(substr($file_path, 1))) {
+        return $path;
+      }

I cannot really express that, but I think we could use Url::fromUri to validate a good bunch of the stuff on the method.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

#15 seems like this needs work

fabianx’s picture

#15: Can you please provide a little more guidance for the contributors on this issue on what you would like to see? Thank you!

aerozeppelin’s picture

Status: Needs work » Needs review
StatusFileSize
new2.61 KB

Rerolled the patch as per comments in #15.

makbul_khan8’s picture

Assigned: makbul_khan8 » Unassigned
makbul_khan8’s picture

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

drzraf’s picture

StatusFileSize
new506 bytes

Status: Needs review » Needs work

The last submitted patch, 22: allow-scheme-agnostic-url-for-logo.patch, failed testing.

yogeshmpawar’s picture

Status: Needs work » Needs review
StatusFileSize
new2.58 KB

Updated patch against 8.4.x branch.

yogeshmpawar’s picture

Any Update on this issue ?

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

markhalliwell’s picture

Status: Needs review » Needs work
Issue tags: -patch, -Logo, -https, -url, -Needs backport to D7 +Needs reroll, +Needs tests

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

MerryHamster’s picture

StatusFileSize
new2.65 KB

reroll patch from #24 to 8.7.x

MerryHamster’s picture

Status: Needs work » Needs review
borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Back to rtbc.

jofitz’s picture

Issue tags: -Needs reroll
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/system/src/Form/ThemeSettingsForm.php
    @@ -491,6 +492,17 @@ protected function validatePath($path) {
    +    if (strncmp($path, "//", 2) == 0) {
    +      $http_path = Url::fromUri('http:' . $path)->toString();
    +      $parsed_url = parse_url($http_path);
    +      $file_path = $parsed_url['path'];
    +      if (is_file(substr($file_path, 1))) {
    +        return $path;
    +      }
    +    }
    

    This is capable of throwing \InvalidArgumentException - these exceptions shouldn't make it through to the user and so need to be caught. That said reading the fromUri code I'm not that sure what we are getting here. I know @dawehner asked for something but there no additional validation and we're having to call parse_url twice. For me this is simpler as:

        // Scheme-independent URL (dual HTTP/HTTPS) are valid.
        if (strncmp($path, "//", 2) == 0) {
          $parsed_url = parse_url('http:' . $path);
          if (isset($parsed_url['path']) && is_file(substr($parsed_url['path'], 1))) {
            return $path;
          }
          return FALSE;
        }
    

    Also independent is spelt wrong.

  2. +++ b/core/modules/system/tests/src/Functional/System/ThemeTest.php
    @@ -156,6 +163,7 @@ public function testThemeSettings() {
    +      '//core/misc/whatever.png',
    

    Needs a descriptive comment above it like the rest and perhaps we could add some more invalid scheme-independent URLs for testing.

  3. Another thing that we might need is some sort of UI text change to say this is supported. What makes this difficult is that the existing favicon and logo files don't have great descriptions that are easy to change.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

smustgrave’s picture

This came up as a daily BSI target.

Seems this got left on #34 feedback which appears valid.

IS should also follow issue template

Thanks.