Verified Commit 5e86af6e authored by Dave Long's avatar Dave Long
Browse files

Issue #3399685 by poker10, greggles, BramDriesen: Remove Core version from...

Issue #3399685 by poker10, greggles, BramDriesen: Remove Core version from install.php when the site already is installed - Information Disclosure - Leaking version information

(cherry picked from commit 4c95ce55)
parent ea99cad0
Loading
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
use Drupal\Core\Render\Element;
use Drupal\Core\Render\Markup;
use Drupal\Core\Utility\TableSort;
use Drupal\Core\Installer\InstallerKernel;

/**
 * @defgroup content_flags Content markers
@@ -1505,13 +1506,18 @@ function template_preprocess_maintenance_page(&$variables) {
 * @see template_preprocess_maintenance_page()
 */
function template_preprocess_install_page(&$variables) {
  $installer_active_task = NULL;
  if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE === 'install' && InstallerKernel::installationAttempted()) {
    $installer_active_task = $GLOBALS['install_state']['active_task'];
  }

  template_preprocess_maintenance_page($variables);

  // Override the site name that is displayed on the page, since Drupal is
  // still in the process of being installed.
  $distribution_name = drupal_install_profile_distribution_name();
  $variables['site_name'] = $distribution_name;
  $variables['site_version'] = drupal_install_profile_distribution_version();
  $variables['site_version'] = $installer_active_task ? drupal_install_profile_distribution_version() : '';
}

/**
+3 −0
Original line number Diff line number Diff line
@@ -22,6 +22,9 @@ public function testInstaller() {
    $this->visitInstaller();
    $this->assertSession()->pageTextContains('Drupal already installed');

    // Verify that Drupal version is not displayed.
    $this->assertSession()->pageTextNotContains(\Drupal::VERSION);

    // Delete settings.php and attempt to reinstall again.
    unlink($this->siteDirectory . '/settings.php');
    $this->visitInstaller();