From 67db1c6e9bc474c34cb10029794b64be8c85a393 Mon Sep 17 00:00:00 2001 From: Hilmar R Date: Sat, 23 Jan 2021 15:24:24 +0100 Subject: melt diff prod fork 4.6.2 air onto 5.2.1 to 5.2.2 DB 1241 --- include/text.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index d6b196f1e..96e5c7882 100644 --- a/include/text.php +++ b/include/text.php @@ -2313,6 +2313,18 @@ function undo_post_tagging($s) { return $s; } +/** + * @brief php to js string transfer + * Hilmar, 20200227 + * String values built in php for using as content for js variables become sanitized. Often required + * in cases, where some content will be translated by t(any text...) and is furthermore transfered via + * templates to the outputted html stream. Redecoding in js not required nor useful. + * Apply like: p2j(t('any text\nI will place on a "next line"')); + */ +function p2j($string) { + return preg_replace('/\r?\n/', '\\n', addslashes($string)); +} + function quote_tag($s) { if(strpos($s,' ') !== false) return '"' . $s . '"'; -- cgit v1.2.3