From 2c82b9f686fb347465db2686ebf077b5eee46950 Mon Sep 17 00:00:00 2001
From: koustav_mondal <koustav.mondal@innoraft.com>
Date: Tue, 4 Mar 2025 15:25:45 +0530
Subject: [PATCH 1/2] Issue #3508843 by koustav_mondal: Replace
 http://example.com with https://example.com in core/lib

---
 core/lib/Drupal/Component/Utility/Html.php             |  8 ++++----
 core/lib/Drupal/Component/Utility/UrlHelper.php        | 10 +++++-----
 .../Drupal/Core/Action/Plugin/Action/GotoAction.php    |  2 +-
 core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php  |  4 ++--
 .../lib/Drupal/Core/Cache/Context/SiteCacheContext.php |  2 +-
 core/lib/Drupal/Core/File/FileUrlGenerator.php         |  8 ++++----
 .../Core/Routing/LocalAwareRedirectResponseTrait.php   |  2 +-
 core/lib/Drupal/Core/Routing/RequestContext.php        |  2 +-
 core/lib/Drupal/Core/Routing/RequestHelper.php         |  4 ++--
 core/lib/Drupal/Core/Url.php                           |  2 +-
 .../lib/Drupal/Core/Utility/LinkGeneratorInterface.php |  2 +-
 .../Core/Utility/UnroutedUrlAssemblerInterface.php     |  4 ++--
 12 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/core/lib/Drupal/Component/Utility/Html.php b/core/lib/Drupal/Component/Utility/Html.php
index dc9fbb267576..38b328a4c61c 100644
--- a/core/lib/Drupal/Component/Utility/Html.php
+++ b/core/lib/Drupal/Component/Utility/Html.php
@@ -441,11 +441,11 @@ public static function escape(string $text): string {
    * change other relative URLs because they would result in different absolute
    * URLs depending on the current path. For example: when the same content
    * containing such a relative URL (for example 'image.png'), is served from
-   * its canonical URL (for example 'http://example.com/some-article') or from
-   * a listing or feed (for example 'http://example.com/all-articles') their
+   * its canonical URL (for example 'https://example.com/some-article') or from
+   * a listing or feed (for example 'https://example.com/all-articles') their
    * "current path" differs, resulting in different absolute URLs:
-   * 'http://example.com/some-article/image.png' versus
-   * 'http://example.com/all-articles/image.png'. Only one can be correct.
+   * 'https://example.com/some-article/image.png' versus
+   * 'https://example.com/all-articles/image.png'. Only one can be correct.
    * Therefore relative URLs that are not root-relative cannot be safely
    * transformed and should generally be avoided.
    *
diff --git a/core/lib/Drupal/Component/Utility/UrlHelper.php b/core/lib/Drupal/Component/Utility/UrlHelper.php
index 9ad996c23980..688c01c2d4dd 100644
--- a/core/lib/Drupal/Component/Utility/UrlHelper.php
+++ b/core/lib/Drupal/Component/Utility/UrlHelper.php
@@ -216,7 +216,7 @@ public static function parse($url) {
     else {
       // parse_url() does not support relative URLs, so make it absolute. For
       // instance, the relative URL "foo/bar:1" isn't properly parsed.
-      $parts = parse_url('http://example.com/' . $url);
+      $parts = parse_url('https://example.com/' . $url);
       // Strip the leading slash that was just added.
       $options['path'] = substr($parts['path'], 1);
       if (isset($parts['query'])) {
@@ -248,13 +248,13 @@ public static function encodePath($path) {
   /**
    * Determines whether a path is external to Drupal.
    *
-   * An example of an external path is http://example.com. If a path cannot be
+   * An example of an external path is https://example.com. If a path cannot be
    * assessed by Drupal's menu handler, then we must treat it as potentially
    * insecure.
    *
    * @param string $path
    *   The internal path or external URL being linked to, such as "node/34" or
-   *   "http://example.com/foo".
+   *   "https://example.com/foo".
    *
    * @return bool
    *   TRUE or FALSE, where TRUE indicates an external path.
@@ -283,9 +283,9 @@ public static function isExternal($path) {
    * Determines if an external URL points to this installation.
    *
    * @param string $url
-   *   A string containing an external URL, such as "http://example.com/foo".
+   *   A string containing an external URL, such as "https://example.com/foo".
    * @param string $base_url
-   *   The base URL string to check against, such as "http://example.com/"
+   *   The base URL string to check against, such as "https://example.com/"
    *
    * @return bool
    *   TRUE if the URL has the same domain and base path.
diff --git a/core/lib/Drupal/Core/Action/Plugin/Action/GotoAction.php b/core/lib/Drupal/Core/Action/Plugin/Action/GotoAction.php
index 92e92e006489..55b746de6cec 100644
--- a/core/lib/Drupal/Core/Action/Plugin/Action/GotoAction.php
+++ b/core/lib/Drupal/Core/Action/Plugin/Action/GotoAction.php
@@ -116,7 +116,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
     $form['url'] = [
       '#type' => 'textfield',
       '#title' => $this->t('URL'),
-      '#description' => $this->t('The URL to which the user should be redirected. This can be an internal URL like /node/1234 or an external URL like @url.', ['@url' => 'http://example.com']),
+      '#description' => $this->t('The URL to which the user should be redirected. This can be an internal URL like /node/1234 or an external URL like @url.', ['@url' => 'https://example.com']),
       '#default_value' => $this->configuration['url'],
       '#required' => TRUE,
     ];
diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
index 78097760f493..197d935909de 100644
--- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
+++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
@@ -261,7 +261,7 @@ public function buildByExtension($extension) {
             elseif ($this->streamWrapperManager->isValidUri($source)) {
               $options['data'] = $source;
             }
-            // A regular URI (e.g., http://example.com/example.js) without
+            // A regular URI (e.g., https://example.com/example.js) without
             // 'external' explicitly specified, which may happen if, e.g.
             // libraries-override is used.
             elseif ($this->isValidUri($source)) {
@@ -634,7 +634,7 @@ protected function setOverrideValue(array &$library, array $sub_key, array $over
   protected function resolveThemeAssetPath($theme_path, $overriding_asset) {
     if ($overriding_asset[0] !== '/' && !$this->isValidUri($overriding_asset)) {
       // The destination is not an absolute path and it's not a URI (e.g.
-      // public://generated_js/example.js or http://example.com/js/my_js.js), so
+      // public://generated_js/example.js or https://example.com/js/my_js.js), so
       // it's relative to the theme.
       return '/' . $theme_path . '/' . $overriding_asset;
     }
diff --git a/core/lib/Drupal/Core/Cache/Context/SiteCacheContext.php b/core/lib/Drupal/Core/Cache/Context/SiteCacheContext.php
index 16516c5e2f82..6291c084a3d5 100644
--- a/core/lib/Drupal/Core/Cache/Context/SiteCacheContext.php
+++ b/core/lib/Drupal/Core/Cache/Context/SiteCacheContext.php
@@ -12,7 +12,7 @@
  * A "site" is defined as the combination of URI scheme, domain name, port and
  * base path. It allows for varying between the *same* site being accessed via
  * different entry points. (Different sites in a multisite setup have separate
- * databases.) For example: http://example.com and http://www.example.com.
+ * databases.) For example: https://example.com and http://www.example.com.
  *
  * @see \Symfony\Component\HttpFoundation\Request::getSchemeAndHttpHost()
  * @see \Symfony\Component\HttpFoundation\Request::getBaseUrl()
diff --git a/core/lib/Drupal/Core/File/FileUrlGenerator.php b/core/lib/Drupal/Core/File/FileUrlGenerator.php
index 3f32d485a69c..82f080cb96f5 100644
--- a/core/lib/Drupal/Core/File/FileUrlGenerator.php
+++ b/core/lib/Drupal/Core/File/FileUrlGenerator.php
@@ -119,9 +119,9 @@ protected function doGenerateString(string $uri, bool $relative): string {
    */
   protected function generatePath(string $base_url, string $uri): string {
     // Allow for:
-    // - root-relative URIs (e.g. /foo.jpg in http://example.com/foo.jpg)
+    // - root-relative URIs (e.g. /foo.jpg in https://example.com/foo.jpg)
     // - protocol-relative URIs (e.g. //bar.jpg, which is expanded to
-    //   http://example.com/bar.jpg by the browser when viewing a page over
+    //   https://example.com/bar.jpg by the browser when viewing a page over
     //   HTTP and to https://example.com/bar.jpg when viewing a HTTPS page)
     // Both types of relative URIs are characterized by a leading slash, hence
     // we can use a single check.
@@ -160,9 +160,9 @@ public function generate(string $uri): Url {
 
     if (!$scheme) {
       // Allow for:
-      // - root-relative URIs (e.g. /foo.jpg in http://example.com/foo.jpg)
+      // - root-relative URIs (e.g. /foo.jpg in https://example.com/foo.jpg)
       // - protocol-relative URIs (e.g. //bar.jpg, which is expanded to
-      //   http://example.com/bar.jpg by the browser when viewing a page over
+      //   https://example.com/bar.jpg by the browser when viewing a page over
       //   HTTP and to https://example.com/bar.jpg when viewing a HTTPS page)
       // Both types of relative URIs are characterized by a leading slash, hence
       // we can use a single check.
diff --git a/core/lib/Drupal/Core/Routing/LocalAwareRedirectResponseTrait.php b/core/lib/Drupal/Core/Routing/LocalAwareRedirectResponseTrait.php
index 521feaf19f93..1efd5d569f66 100644
--- a/core/lib/Drupal/Core/Routing/LocalAwareRedirectResponseTrait.php
+++ b/core/lib/Drupal/Core/Routing/LocalAwareRedirectResponseTrait.php
@@ -21,7 +21,7 @@ trait LocalAwareRedirectResponseTrait {
    *
    * @param string $url
    *   The internal path or external URL being linked to, such as "node/34" or
-   *   "http://example.com/foo".
+   *   "https://example.com/foo".
    *
    * @return bool
    *   TRUE or FALSE, where TRUE indicates a local path.
diff --git a/core/lib/Drupal/Core/Routing/RequestContext.php b/core/lib/Drupal/Core/Routing/RequestContext.php
index 24f196079b99..0f8948da175b 100644
--- a/core/lib/Drupal/Core/Routing/RequestContext.php
+++ b/core/lib/Drupal/Core/Routing/RequestContext.php
@@ -12,7 +12,7 @@
 class RequestContext extends SymfonyRequestContext {
 
   /**
-   * The scheme, host and base path, for example "http://example.com/d8".
+   * The scheme, host and base path, for example "https://example.com/d8".
    *
    * @var string
    */
diff --git a/core/lib/Drupal/Core/Routing/RequestHelper.php b/core/lib/Drupal/Core/Routing/RequestHelper.php
index 23063901a0b2..c9dc980aceb7 100644
--- a/core/lib/Drupal/Core/Routing/RequestHelper.php
+++ b/core/lib/Drupal/Core/Routing/RequestHelper.php
@@ -13,8 +13,8 @@ class RequestHelper {
    * Returns whether the request is using a clean URL.
    *
    * A clean URL is one that does not include the script name. For example,
-   * - http://example.com/node/1 is a clean URL.
-   * - http://example.com/index.php/node/1 is not a clean URL.
+   * - https://example.com/node/1 is a clean URL.
+   * - https://example.com/index.php/node/1 is not a clean URL.
    *
    * Unclean URLs are required on sites hosted by web servers that cannot be
    * configured to implicitly route URLs to index.php.
diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php
index 8f0de5f32244..023fe9210f12 100644
--- a/core/lib/Drupal/Core/Url.php
+++ b/core/lib/Drupal/Core/Url.php
@@ -753,7 +753,7 @@ public function setAbsolute($absolute = TRUE) {
    * If this Url object was constructed from a Drupal route or from an internal
    * URI (URIs using the internal:, base:, or entity: schemes), the returned
    * string will either be a relative URL like /node/1 or an absolute URL like
-   * http://example.com/node/1 depending on the options array, plus any
+   * https://example.com/node/1 depending on the options array, plus any
    * specified query string or fragment.
    *
    * @param bool $collect_bubbleable_metadata
diff --git a/core/lib/Drupal/Core/Utility/LinkGeneratorInterface.php b/core/lib/Drupal/Core/Utility/LinkGeneratorInterface.php
index e4c48eed0fc5..edfe809c7a03 100644
--- a/core/lib/Drupal/Core/Utility/LinkGeneratorInterface.php
+++ b/core/lib/Drupal/Core/Utility/LinkGeneratorInterface.php
@@ -17,7 +17,7 @@ interface LinkGeneratorInterface {
    * $link_generator = \Drupal::service('link_generator');
    * $installer_url = \Drupal\Core\Url::fromUri('base://core/install.php');
    * $installer_link = $link_generator->generate($text, $installer_url);
-   * $external_url = \Drupal\Core\Url::fromUri('http://example.com', ['query' => ['foo' => 'bar']]);
+   * $external_url = \Drupal\Core\Url::fromUri('https://example.com', ['query' => ['foo' => 'bar']]);
    * $external_link = $link_generator->generate($text, $external_url);
    * $internal_url = \Drupal\Core\Url::fromRoute('system.admin');
    * $internal_link = $link_generator->generate($text, $internal_url);
diff --git a/core/lib/Drupal/Core/Utility/UnroutedUrlAssemblerInterface.php b/core/lib/Drupal/Core/Utility/UnroutedUrlAssemblerInterface.php
index 51cdf1885350..5d087cf8b136 100644
--- a/core/lib/Drupal/Core/Utility/UnroutedUrlAssemblerInterface.php
+++ b/core/lib/Drupal/Core/Utility/UnroutedUrlAssemblerInterface.php
@@ -15,7 +15,7 @@ interface UnroutedUrlAssemblerInterface {
    *
    * @param string $uri
    *   A local URI or an external URL being linked to, such as "base:foo"
-   *    or "http://example.com/foo".
+   *    or "https://example.com/foo".
    *   - If you provide a full URL, it will be considered an external URL as
    *     long as it has an allowed protocol.
    *   - If you provide only a local URI (e.g. "base:foo"), it will be
@@ -24,7 +24,7 @@ interface UnroutedUrlAssemblerInterface {
    *     is found) will be added to the path. Additional query arguments for
    *     local paths must be supplied in $options['query'], not part of $uri.
    *   - If your external URL contains a query (e.g.
-   *     http://example.com/foo?a=b), then you can either URL encode the query
+   *     https://example.com/foo?a=b), then you can either URL encode the query
    *     keys and values yourself and include them in $uri, or use
    *     $options['query'] to let this method URL encode them.
    * @param array $options
-- 
GitLab


From b3d409d01c376a611ab2794da5cfa2cdb50d29bb Mon Sep 17 00:00:00 2001
From: koustav_mondal <koustav.mondal@innoraft.com>
Date: Tue, 4 Mar 2025 15:33:51 +0530
Subject: [PATCH 2/2] Issue #3508843: Fix PhpStan issue.

---
 core/lib/Drupal/Component/Utility/UrlHelper.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/lib/Drupal/Component/Utility/UrlHelper.php b/core/lib/Drupal/Component/Utility/UrlHelper.php
index 688c01c2d4dd..9619dcf07031 100644
--- a/core/lib/Drupal/Component/Utility/UrlHelper.php
+++ b/core/lib/Drupal/Component/Utility/UrlHelper.php
@@ -285,7 +285,7 @@ public static function isExternal($path) {
    * @param string $url
    *   A string containing an external URL, such as "https://example.com/foo".
    * @param string $base_url
-   *   The base URL string to check against, such as "https://example.com/"
+   *   The base URL string to check against, such as "https://example.com/".
    *
    * @return bool
    *   TRUE if the URL has the same domain and base path.
-- 
GitLab