From 37fa55e7cf41f896f5cf22ed0ae486b4f293a2d2 Mon Sep 17 00:00:00 2001 From: Anton Evers Date: Fri, 21 Apr 2017 11:27:57 +0200 Subject: [PATCH] Make deployed_version.txt editor friendly In production environments with a CDN for static files it comes in handy that you can force a browser cache refresh by changing the number manually without having to go into maintenance for a full deploy. If you edit the `pub/static/deployed_version.txt` with vim, nano or `echo '123456789' > pub/static/deployed_version.txt` you can unintentionally create a newline at the end of the file. This will result in: ```html var BASE_URL = 'https://magento2.dev/sitemanager/admin/index/index/key/ec38dd3ded42b71db14166d6bcdfc56d4e7d4b7801b9808373ae4b3563b65513/'; var FORM_KEY = 'dKArsQU6NhimXr6Z'; var require = { "baseUrl": "https://magento2.dev/pub/static/version1492766286 /adminhtml/Magento/backend/en_US" }; ``` With that baseUrl all resources using baseUrl will return the 404 page. Adding a simple `trim()` here will remove that risk. --- .../Framework/App/View/Deployment/Version/Storage/File.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/App/View/Deployment/Version/Storage/File.php b/lib/internal/Magento/Framework/App/View/Deployment/Version/Storage/File.php index 8099b6864b3a1..21dc6dd1fc214 100644 --- a/lib/internal/Magento/Framework/App/View/Deployment/Version/Storage/File.php +++ b/lib/internal/Magento/Framework/App/View/Deployment/Version/Storage/File.php @@ -41,7 +41,7 @@ public function __construct( public function load() { if ($this->directory->isReadable($this->fileName)) { - return $this->directory->readFile($this->fileName); + return trim($this->directory->readFile($this->fileName)); } return false; }