Use script_src for <script src>

This commit is contained in:
Jakub Vrana 2018-01-13 16:25:11 +01:00
parent 144c7de27f
commit 9d532fc0a1
8 changed files with 34 additions and 23 deletions

View 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) {

View 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">

View 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

View 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(""),

View file

@ -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);

View 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']); });");
}
}

View 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',

View 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);
}
}