]> git.joonet.de Git - adminer.git/commitdiff
Use script_src for <script src>
authorJakub Vrana <jakub@vrana.cz>
Sat, 13 Jan 2018 15:25:11 +0000 (16:25 +0100)
committerJakub Vrana <jakub@vrana.cz>
Sat, 13 Jan 2018 15:25:11 +0000 (16:25 +0100)
adminer/include/adminer.inc.php
adminer/include/design.inc.php
adminer/include/functions.inc.php
adminer/plugin.php
compile.php
plugins/edit-calendar.php
plugins/tinymce.php
plugins/wymeditor.php

index d0db5644c42436f5db897db08fb1b3d3806c51b1..aed9e0e3ad042b02833971c632bf3620faef00af 100644 (file)
@@ -890,15 +890,13 @@ class Adminer {
                                $connection->select_db(DB);
                                $tables = table_status('', true);
                        }
-                       ?>
-<script src="../externals/jush/modules/jush.js"></script>
-<script src="../externals/jush/modules/jush-textarea.js"></script>
-<script src="../externals/jush/modules/jush-txt.js"></script>
-<script src="../externals/jush/modules/jush-js.js"></script>
-<?php
+                       echo script_src("../externals/jush/modules/jush.js");
+                       echo script_src("../externals/jush/modules/jush-textarea.js");
+                       echo script_src("../externals/jush/modules/jush-txt.js");
+                       echo script_src("../externals/jush/modules/jush-js.js");
                        if (support("sql")) {
+                               echo script_src("../externals/jush/modules/jush-$jush.js");
                                ?>
-<script src="../externals/jush/modules/jush-<?php echo $jush; ?>.js"></script>
 <script>
 <?php
                                if ($tables) {
index ad79bd6984c3d5b87fcab5380fcdfb6d52d1afc9..4fc6842c6b2d1f2468586870999e3e57f3837ea6 100644 (file)
@@ -22,8 +22,8 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
 <meta name="robots" content="noindex">
 <title><?php echo $title_page; ?></title>
 <link rel="stylesheet" type="text/css" href="../adminer/static/default.css">
-<script src="../adminer/static/functions.js"></script>
-<script src="static/editing.js"></script>
+<?php echo script_src("../adminer/static/functions.js"); ?>
+<?php echo script_src("static/editing.js"); ?>
 <?php if ($adminer->head()) { ?>
 <link rel="shortcut icon" type="image/x-icon" href="../adminer/static/favicon.ico">
 <link rel="apple-touch-icon" href="../adminer/static/favicon.ico">
index 0768c56b6d386a8cb434539b55ca23ebf3bb7501..6cfc0108b9d367855777469f2159668229967546 100644 (file)
@@ -90,6 +90,14 @@ function script($source, $trailing = "\n") {
        return "<script>$source</script>$trailing";
 }
 
+/** Return <script src> element
+* @param string
+* @return string
+*/
+function script_src($url) {
+       return "<script src='" . h($url) . "'></script>\n";
+}
+
 /** Escape for HTML
 * @param string
 * @return string
index 7b241973b510567e683595add31c3372373b57bd..3fb1b549a30d432ac5c0191da368d1403cb112cb 100644 (file)
@@ -17,7 +17,7 @@ function adminer_object() {
                new AdminerDumpXml,
                new AdminerDumpAlter,
                //~ new AdminerSqlLog("past-" . rtrim(`git describe --tags --abbrev=0`) . ".sql"),
-               //~ new AdminerEditCalendar("<script src='../externals/jquery-ui/jquery-1.4.4.js'></script>\n<script src='../externals/jquery-ui/ui/jquery.ui.core.js'></script>\n<script src='../externals/jquery-ui/ui/jquery.ui.widget.js'></script>\n<script src='../externals/jquery-ui/ui/jquery.ui.datepicker.js'></script>\n<script src='../externals/jquery-ui/ui/jquery.ui.mouse.js'></script>\n<script src='../externals/jquery-ui/ui/jquery.ui.slider.js'></script>\n<script src='../externals/jquery-timepicker/jquery-ui-timepicker-addon.js'></script>\n<link rel='stylesheet' href='../externals/jquery-ui/themes/base/jquery.ui.all.css'>\n<style>\n.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }\n.ui-timepicker-div dl { text-align: left; }\n.ui-timepicker-div dl dt { height: 25px; }\n.ui-timepicker-div dl dd { margin: -25px 0 10px 65px; }\n.ui-timepicker-div td { font-size: 90%; }\n</style>\n", "../externals/jquery-ui/ui/i18n/jquery.ui.datepicker-%s.js"),
+               //~ new AdminerEditCalendar(script_src("../externals/jquery-ui/jquery-1.4.4.js") . script_src("../externals/jquery-ui/ui/jquery.ui.core.js") . script_src("../externals/jquery-ui/ui/jquery.ui.widget.js") . script_src("../externals/jquery-ui/ui/jquery.ui.datepicker.js") . script_src("../externals/jquery-ui/ui/jquery.ui.mouse.js") . script_src("../externals/jquery-ui/ui/jquery.ui.slider.js") . script_src("../externals/jquery-timepicker/jquery-ui-timepicker-addon.js") . "<link rel='stylesheet' href='../externals/jquery-ui/themes/base/jquery.ui.all.css'>\n<style>\n.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }\n.ui-timepicker-div dl { text-align: left; }\n.ui-timepicker-div dl dt { height: 25px; }\n.ui-timepicker-div dl dd { margin: -25px 0 10px 65px; }\n.ui-timepicker-div td { font-size: 90%; }\n</style>\n", "../externals/jquery-ui/ui/i18n/jquery.ui.datepicker-%s.js"),
                //~ new AdminerTinymce("../externals/tinymce/jscripts/tiny_mce/tiny_mce_dev.js"),
                //~ new AdminerWymeditor(array("../externals/wymeditor/src/jquery/jquery.js", "../externals/wymeditor/src/wymeditor/jquery.wymeditor.js", "../externals/wymeditor/src/wymeditor/jquery.wymeditor.explorer.js", "../externals/wymeditor/src/wymeditor/jquery.wymeditor.mozilla.js", "../externals/wymeditor/src/wymeditor/jquery.wymeditor.opera.js", "../externals/wymeditor/src/wymeditor/jquery.wymeditor.safari.js")),
                new AdminerFileUpload(""),
index 5e635ec9b14f3db72f4eb2008420b316cd68d589..a28b94622094b5b1701dc6b76ccb3a53c19da8ca 100755 (executable)
@@ -393,17 +393,15 @@ if ($_SESSION["lang"]) {
        $file = str_replace("<?php switch_lang(); ?>\n", "", $file);
        $file = str_replace('<?php echo $LANG; ?>', $_SESSION["lang"], $file);
 }
-$file = str_replace('<script src="static/editing.js"></script>' . "\n", "", $file);
-$file = str_replace('<script src="../externals/jush/modules/jush-textarea.js"></script>' . "\n", "", $file);
-$file = str_replace('<script src="../externals/jush/modules/jush-txt.js"></script>' . "\n", "", $file);
-$file = str_replace('<script src="../externals/jush/modules/jush-js.js"></script>' . "\n", "", $file);
-$file = str_replace('<script src="../externals/jush/modules/jush-<?php echo $jush; ?>.js"></script>' . "\n", "", $file);
+$file = str_replace('<?php echo script_src("static/editing.js"); ?>' . "\n", "", $file);
+$file = preg_replace('~\\s+echo script_src\\("\\.\\./externals/jush/modules/jush-(textarea|txt|js|\\$jush)\\.js"\\);~', '', $file);
 $file = str_replace('<link rel="stylesheet" type="text/css" href="../externals/jush/jush.css">' . "\n", "", $file);
 $file = preg_replace_callback("~compile_file\\('([^']+)'(?:, '([^']*)')?\\)~", 'compile_file', $file); // integrate static files
-$replace = 'h(preg_replace("~\\\\\\\\?.*~", "", ME)) . "?file=\\1&amp;version=' . $VERSION . ($driver ? '&amp;driver=' . $driver : '');
-$file = preg_replace('~\\.\\./adminer/static/(default\\.css|functions\\.js|favicon\\.ico)~', '<?php echo ' . $replace . '"; ?>', $file);
-$file = preg_replace('~\\.\\./adminer/static/([^\'"]*)~', '" . ' . $replace, $file);
-$file = preg_replace('~\\.\\./externals/jush/modules/(jush\\.js)~', '<?php echo ' . $replace . '"; ?>', $file);
+$replace = 'preg_replace("~\\\\\\\\?.*~", "", ME) . "?file=\\1&version=' . $VERSION . ($driver ? '&driver=' . $driver : '') . '"';
+$file = preg_replace('~\\.\\./adminer/static/(default\\.css|favicon\\.ico)~', '<?php echo h(' . $replace . '); ?>', $file);
+$file = preg_replace('~"\\.\\./adminer/static/(functions\\.js)"~', $replace, $file);
+$file = preg_replace('~\\.\\./adminer/static/([^\'"]*)~', '" . h(' . $replace . ') . "', $file);
+$file = preg_replace('~"\\.\\./externals/jush/modules/(jush\\.js)"~', $replace, $file);
 $file = preg_replace("~<\\?php\\s*\\?>\n?|\\?>\n?<\\?php~", '', $file);
 $file = php_shrink($file);
 
index 745dd8e41abb49a5b1c980eab3f120057bab015b..11fec866f71e2d924d4d2663c6ef62cb42dd6ac5 100644 (file)
@@ -16,7 +16,14 @@ class AdminerEditCalendar {
        * @param string text to append before first calendar usage
        * @param string path to language file, %s stands for language code
        */
-       function __construct($prepend = "<script src='jquery-ui/jquery.js'></script>\n<script src='jquery-ui/jquery-ui.js'></script>\n<script src='jquery-ui/jquery-ui-timepicker-addon.js'></script>\n<link rel='stylesheet' type='text/css' href='jquery-ui/jquery-ui.css'>\n", $langPath = "jquery-ui/i18n/jquery.ui.datepicker-%s.js") {
+       function __construct($prepend = null, $langPath = "jquery-ui/i18n/jquery.ui.datepicker-%s.js") {
+               if ($prepend === null) {
+                       $prepend = "<link rel='stylesheet' type='text/css' href='jquery-ui/jquery-ui.css'>\n"
+                               . script_src("jquery-ui/jquery.js")
+                               . script_src("jquery-ui/jquery-ui.js")
+                               . script_src("jquery-ui/jquery-ui-timepicker-addon.js")
+                       ;
+               }
                $this->prepend = $prepend;
                $this->langPath = $langPath;
        }
@@ -27,7 +34,7 @@ class AdminerEditCalendar {
                        $lang = get_lang();
                        $lang = ($lang == "zh" ? "zh-CN" : ($lang == "zh-tw" ? "zh-TW" : $lang));
                        if ($lang != "en" && file_exists(sprintf($this->langPath, $lang))) {
-                               printf("<script src='$this->langPath'></script>\n", $lang);
+                               echo script_src(sprintf($this->langPath, $lang));
                                echo script("jQuery(function () { jQuery.timepicker.setDefaults(jQuery.datepicker.regional['$lang']); });");
                        }
                }
index 1425b04559c188c42bdbff2cf91e5bea10c24e67..59620a01a68a15bfad8d421528fd0b9d0830b28a 100644 (file)
@@ -27,8 +27,8 @@ class AdminerTinymce {
                                $lang = "en";
                        }
                }
+               echo script_src($this->path);
                ?>
-<script src="<?php echo h($this->path); ?>"></script>
 <script>
 tinyMCE.init({
        mode: 'none',
index 8944fe847fc0cf5be50a419b43819db29e29bae8..e21992478152592ebd5acc7f09b5266241add359 100644 (file)
@@ -22,7 +22,7 @@ class AdminerWymeditor {
 
        function head() {
                foreach ($this->scripts as $script) {
-                       echo "<script src='" . h($script) . "'></script>\n";
+                       echo script_src($script);
                }
        }