Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'core/Common.php')
-rw-r--r--core/Common.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/core/Common.php b/core/Common.php
index 90ceda1d4f..08751d5cbe 100644
--- a/core/Common.php
+++ b/core/Common.php
@@ -577,6 +577,38 @@ class Common
return $value;
}
+ /**
+ * Replaces lbrace with an encoded entity to prevent angular from parsing the content
+ *
+ * @deprecated Will be removed, once the vue js migration is done
+ *
+ * @param $string
+ * @return array|string|string[]|null
+ */
+ public static function fixLbrace($string)
+ {
+ $chars = array('{', '{', '{', '{', '{', '{');
+
+ static $search;
+ static $replace;
+
+ if (!isset($search)) {
+ $search = array_map(function ($val) { return $val . $val; }, $chars);
+ }
+ if (!isset($replace)) {
+ $replace = array_map(function ($val) { return $val . '⁣' . $val; }, $chars);
+ }
+
+ $replacedString = is_null($string) ? $string : str_replace($search, $replace, $string);
+
+ // try to replace characters until there are no changes
+ if ($string !== $replacedString) {
+ return self::fixLbrace($replacedString);
+ }
+
+ return $string;
+ }
+
/*
* Generating unique strings
*/