aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
authorHilmar R <u02@u29lx193>2021-01-23 15:24:24 +0100
committerHilmar R <u02@u29lx193>2021-01-23 15:24:24 +0100
commit67db1c6e9bc474c34cb10029794b64be8c85a393 (patch)
tree46619d97bafb88b4649629c0dfb370f1ddf6e5dc /include/text.php
parentabdf6f40a2712e31fe97d1d059bfea57a78be257 (diff)
downloadvolse-hubzilla-67db1c6e9bc474c34cb10029794b64be8c85a393.tar.gz
volse-hubzilla-67db1c6e9bc474c34cb10029794b64be8c85a393.tar.bz2
volse-hubzilla-67db1c6e9bc474c34cb10029794b64be8c85a393.zip
melt diff prod fork 4.6.2 air onto 5.2.1 to 5.2.2 DB 1241
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php12
1 files changed, 12 insertions, 0 deletions
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 '&quot;' . $s . '&quot;';