From ec0a4332a2c31bd0e5a675e000b564cc9445246c Mon Sep 17 00:00:00 2001 From: Georgios Papadakis Date: Sat, 23 Jul 2016 16:31:29 +0300 Subject: [PATCH 1/5] Fix SEF plugin some times breaking HTML while trying to make inline background url paths absolute --- plugins/system/sef/sef.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/system/sef/sef.php b/plugins/system/sef/sef.php index 8622cddfbec9a..88c094cb92930 100644 --- a/plugins/system/sef/sef.php +++ b/plugins/system/sef/sef.php @@ -153,8 +153,8 @@ public function onAfterRender() // Replace all unknown protocols in CSS background image. if (strpos($buffer, 'style=') !== false) { - $regex = '#style=\s*[\'\"](.*):\s*url\s*\([\'\"]?(?!/|' . $protocols . '|\#)([^\)\'\"]+)[\'\"]?\)#m'; - $buffer = preg_replace($regex, 'style="$1: url(\'' . $base . '$2$3\')', $buffer); + $regex = '#style=\s*([\'\"])(.*):\s*url\s*\(([\'\"])?(?!/|' . $protocols . '|\#)([^\)\'\"]+)([\'\"]?)\)#m'; + $buffer = preg_replace($regex, 'style=$1$2: url($3' . $base . '$4$5$6)', $buffer); $this->checkBuffer($buffer); } From 5cb88b11decef0595445452c4354a25d8be74404 Mon Sep 17 00:00:00 2001 From: Georgios Papadakis Date: Wed, 3 Aug 2016 21:46:52 +0300 Subject: [PATCH 2/5] Added handling of " and ' --- plugins/system/sef/sef.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/system/sef/sef.php b/plugins/system/sef/sef.php index 88c094cb92930..d8b6a8ff72a01 100644 --- a/plugins/system/sef/sef.php +++ b/plugins/system/sef/sef.php @@ -153,7 +153,7 @@ public function onAfterRender() // Replace all unknown protocols in CSS background image. if (strpos($buffer, 'style=') !== false) { - $regex = '#style=\s*([\'\"])(.*):\s*url\s*\(([\'\"])?(?!/|' . $protocols . '|\#)([^\)\'\"]+)([\'\"]?)\)#m'; + $regex = '#style=\s*([\'\"])(.*):\s*url\s*\(([\'\"]|\&\#0?3[4|9];)?(?!/|\&\#0?3[4|9];|' . $protocols . '|\#)([^\)\'\"]+)([\'\"]|\&\#0?3[4|9];)?\)#m'; $buffer = preg_replace($regex, 'style=$1$2: url($3' . $base . '$4$5$6)', $buffer); $this->checkBuffer($buffer); } From e6855d75157c2122bf5f11fe95454338562a2b44 Mon Sep 17 00:00:00 2001 From: Georgios Papadakis Date: Wed, 3 Aug 2016 22:05:04 +0300 Subject: [PATCH 3/5] Code style, fix too long line --- plugins/system/sef/sef.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/system/sef/sef.php b/plugins/system/sef/sef.php index d8b6a8ff72a01..e620e3a0e9dfa 100644 --- a/plugins/system/sef/sef.php +++ b/plugins/system/sef/sef.php @@ -153,7 +153,8 @@ public function onAfterRender() // Replace all unknown protocols in CSS background image. if (strpos($buffer, 'style=') !== false) { - $regex = '#style=\s*([\'\"])(.*):\s*url\s*\(([\'\"]|\&\#0?3[4|9];)?(?!/|\&\#0?3[4|9];|' . $protocols . '|\#)([^\)\'\"]+)([\'\"]|\&\#0?3[4|9];)?\)#m'; + $regex_url = '\s*url\s*\(([\'\"]|\&\#0?3[4|9];)?(?!/|\&\#0?3[4|9];|' . $protocols . '|\#)([^\)\'\"]+)([\'\"]|\&\#0?3[4|9];)?\)'; + $regex = '#style=\s*([\'\"])(.*):' . $regex_url . '#m'; $buffer = preg_replace($regex, 'style=$1$2: url($3' . $base . '$4$5$6)', $buffer); $this->checkBuffer($buffer); } From 5d5057e458825fa7823cbd907077f757cdf3dc08 Mon Sep 17 00:00:00 2001 From: ggppdk Date: Sun, 11 Dec 2016 06:55:38 +0200 Subject: [PATCH 4/5] Removed redudant pipe character --- plugins/system/sef/sef.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/system/sef/sef.php b/plugins/system/sef/sef.php index e620e3a0e9dfa..744d1574518f8 100644 --- a/plugins/system/sef/sef.php +++ b/plugins/system/sef/sef.php @@ -153,7 +153,7 @@ public function onAfterRender() // Replace all unknown protocols in CSS background image. if (strpos($buffer, 'style=') !== false) { - $regex_url = '\s*url\s*\(([\'\"]|\&\#0?3[4|9];)?(?!/|\&\#0?3[4|9];|' . $protocols . '|\#)([^\)\'\"]+)([\'\"]|\&\#0?3[4|9];)?\)'; + $regex_url = '\s*url\s*\(([\'\"]|\&\#0?3[49];)?(?!/|\&\#0?3[49];|' . $protocols . '|\#)([^\)\'\"]+)([\'\"]|\&\#0?3[49];)?\)'; $regex = '#style=\s*([\'\"])(.*):' . $regex_url . '#m'; $buffer = preg_replace($regex, 'style=$1$2: url($3' . $base . '$4$5$6)', $buffer); $this->checkBuffer($buffer); From b616e6089d3244bde5ec1f9ef38809ae61ca81da Mon Sep 17 00:00:00 2001 From: Georgios Papadakis Date: Fri, 20 Jan 2017 07:36:45 +0200 Subject: [PATCH 5/5] Update sef.php --- plugins/system/sef/sef.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/system/sef/sef.php b/plugins/system/sef/sef.php index 744d1574518f8..4090baa42780e 100644 --- a/plugins/system/sef/sef.php +++ b/plugins/system/sef/sef.php @@ -155,7 +155,7 @@ public function onAfterRender() { $regex_url = '\s*url\s*\(([\'\"]|\&\#0?3[49];)?(?!/|\&\#0?3[49];|' . $protocols . '|\#)([^\)\'\"]+)([\'\"]|\&\#0?3[49];)?\)'; $regex = '#style=\s*([\'\"])(.*):' . $regex_url . '#m'; - $buffer = preg_replace($regex, 'style=$1$2: url($3' . $base . '$4$5$6)', $buffer); + $buffer = preg_replace($regex, 'style=$1$2: url($3' . $base . '$4$5)', $buffer); $this->checkBuffer($buffer); }