File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -150,7 +150,7 @@ public function show()
150150 // start editor html output
151151 if ($ wr ) {
152152 // sets changed to true when previewed
153- echo ' <script>/*<![CDATA[*/ textChanged = ' . ($ mod ? 'true ' : 'false ' ) . '/*!]]>*/</script> ' ;
153+ tpl_inlineScript ( ' textChanged = ' . ($ mod ? 'true ' : 'false ' ) . '; ' ) ;
154154 }
155155
156156 // print intro locale text (edit, rditrev, or read.txt)
Original file line number Diff line number Diff line change @@ -440,6 +440,30 @@ function _tpl_metaheaders_action($data)
440440 }
441441}
442442
443+ /**
444+ * Output the given script as inline script tag
445+ *
446+ * This function will add the nonce attribute if a nonce is available.
447+ *
448+ * The script is NOT automatically escaped!
449+ *
450+ * @param string $script
451+ * @param bool $return Return or print directly?
452+ * @return string|void
453+ */
454+ function tpl_inlineScript ($ script , $ return = false )
455+ {
456+ $ nonce = getenv ('NONCE ' );
457+ if ($ nonce ) {
458+ $ script = '<script nonce=" ' . $ nonce . '"> ' . $ script . '</script> ' ;
459+ } else {
460+ $ script = '<script> ' . $ script . '</script> ' ;
461+ }
462+
463+ if ($ return ) return $ script ;
464+ echo $ script ;
465+ }
466+
443467/**
444468 * Print a link
445469 *
You can’t perform that action at this time.
0 commit comments