From 4505d4fd9e4c993299b8fdf51bf10563d6d63cf1 Mon Sep 17 00:00:00 2001 From: Lucas Mesquita Borges Date: Sat, 2 May 2020 02:14:37 -0300 Subject: [PATCH] Remove quotes only when attributes do not contains whitespaces --- src/Middleware/RemoveQuotes.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Middleware/RemoveQuotes.php b/src/Middleware/RemoveQuotes.php index 87ef72f..ce6ce7b 100644 --- a/src/Middleware/RemoveQuotes.php +++ b/src/Middleware/RemoveQuotes.php @@ -7,15 +7,15 @@ class RemoveQuotes extends PageSpeed public function apply($buffer) { $replace = [ - '/ src="(.*?)"/' => ' src=$1', - '/ width="(.*?)"/' => ' width=$1', - '/ height="(.*?)"/' => ' height=$1', - '/ name="(.*?)"/' => ' name=$1', - '/ charset="(.*?)"/' => ' charset=$1', - '/ align="(.*?)"/' => ' align=$1', - '/ border="(.*?)"/' => ' border=$1', - '/ crossorigin="(.*?)"/' => ' crossorigin=$1', - '/ type="(.*?)"/' => ' type=$1', + '/ src="(.\S*?)"/' => ' src=$1', + '/ width="(.\S*?)"/' => ' width=$1', + '/ height="(.\S*?)"/' => ' height=$1', + '/ name="(.\S*?)"/' => ' name=$1', + '/ charset="(.\S*?)"/' => ' charset=$1', + '/ align="(.\S*?)"/' => ' align=$1', + '/ border="(.\S*?)"/' => ' border=$1', + '/ crossorigin="(.\S*?)"/' => ' crossorigin=$1', + '/ type="(.\S*?)"/' => ' type=$1', '/\/>/' => '>', ];