Skip to content

Commit e3bcfbf

Browse files
author
Dale Sikkema
committed
MAGETWO-38065: /magento_verion exposes too detailed version information
- return blank page if bad version found
1 parent 454fc6e commit e3bcfbf

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.htaccess

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,4 @@
187187
## If running in cluster environment, uncomment this
188188
## http://developer.yahoo.com/performance/rules.html#etags
189189

190-
#FileETag none
190+
#FileETag none

app/code/Magento/Version/Controller/Index/Index.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\App\Action\Action;
1010
use Magento\Framework\App\Action\Context;
1111
use Magento\Framework\App\ProductMetadataInterface;
12+
use Magento\Framework\Exception\StateException;
1213

1314
/**
1415
* Magento Version controller
@@ -34,12 +35,16 @@ public function __construct(Context $context, ProductMetadataInterface $productM
3435
* Sets the response body to ProductName/Major.MinorVersion (Edition). E.g.: Magento/0.42 (Community). Omits patch
3536
* version from response
3637
*
38+
* @throws StateException
3739
* @return void
3840
*/
3941
public function execute()
4042
{
41-
$fullVersion = explode('.', $this->productMetadata->getVersion());
42-
$majorMinorVersion = $fullVersion[0] . '.' . $fullVersion[1];
43+
$versionParts = explode('.', $this->productMetadata->getVersion());
44+
if(!isset($versionParts[0]) || !isset($versionParts[1])) {
45+
return ; // Major and minor version are not set - return empty response
46+
}
47+
$majorMinorVersion = $versionParts[0] . '.' . $versionParts[1];
4348
$this->getResponse()->setBody(
4449
$this->productMetadata->getName() . '/' .
4550
$majorMinorVersion . ' (' .

0 commit comments

Comments
 (0)