From 616ab034250d2c89026c487540d83855ce6ce5a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come@opensides.be>
Date: Thu, 8 Nov 2018 09:13:29 +0100
Subject: [PATCH] :ambulance: fix(core) Fix infinite loop

issue #5882
---
 include/class_templateHandling.inc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/class_templateHandling.inc b/include/class_templateHandling.inc
index 4b2084d3e..7cc3b6a92 100644
--- a/include/class_templateHandling.inc
+++ b/include/class_templateHandling.inc
@@ -229,10 +229,12 @@ class templateHandling
       return preg_replace('/^%%/', '', $string);
     }
 
-    $vars         = array();
-    while (preg_match('/%([^%]+)%/', $string, $m, PREG_OFFSET_CAPTURE)) {
+    $offset = 0;
+    $vars   = array();
+    while (preg_match('/%([^%]+)%/', $string, $m, PREG_OFFSET_CAPTURE, $offset)) {
       $replace  = static::parseMask($m[1][0], $attrs);
       $vars[]   = array($m[0][1], strlen($m[0][0]), $replace);
+      $offset   = $m[0][1] + strlen($m[0][0]);
     }
 
     $generator = static::iteratePossibleValues($string, $vars, $escapeMethod);
-- 
GitLab