Skip to content

Commit e963bf6

Browse files
committed
disallow JS in template code
1 parent 3133d3b commit e963bf6

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

public_html/lists/admin/inc/magic_quotes.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,33 @@ function removeXss($string)
4444
}
4545
//$string = preg_replace('/<script/im','&lt;script',$string);
4646
$string = htmlspecialchars($string);
47-
4847
return $string;
4948
}
5049

50+
function disableJavascript($content) {
51+
## disallow Javascript
52+
$content = str_ireplace('<script','< script',$content);
53+
$content = str_ireplace('onmouseover','on mouse over',$content);
54+
$content = str_ireplace('onmouseout','on mouse out',$content);
55+
$content = str_ireplace('onmousemove','on mouse move',$content);
56+
$content = str_ireplace('onmousedown','on mouse down',$content);
57+
$content = str_ireplace('onclick','on click',$content);
58+
$content = str_ireplace('ondblclick','on dbl click',$content);
59+
$content = str_ireplace('onload','on load',$content);
60+
$content = str_ireplace('onunload','on unload',$content);
61+
$content = str_ireplace('onerror','on error',$content);
62+
$content = str_ireplace('onresize','on resize',$content);
63+
$content = str_ireplace('onblur','on blue',$content);
64+
$content = str_ireplace('onchange','on change',$content);
65+
$content = str_ireplace('onfocus','on focus',$content);
66+
$content = str_ireplace('onselect','on select',$content);
67+
$content = str_ireplace('onsubmit','on submit',$content);
68+
$content = str_ireplace('onreset','on reset',$content);
69+
$content = str_ireplace('onkeyup','on keyup',$content);
70+
$content = str_ireplace('onkeydown','on keydown',$content);
71+
return $content;
72+
}
73+
5174
/*
5275
foreach ($_POST as $key => $val) {
5376
print "POST: $key = $val<br/>";

public_html/lists/admin/template.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function getTemplateLinks($content)
8080
//$msg = '';
8181
} elseif (!empty($_POST['save']) || !empty($_POST['sendtest'])) { //# let's save when sending a test
8282
$templateok = 1;
83-
$title = $_POST['title'];
83+
$title = strip_tags($_POST['title']);
8484
$req = Sql_Query(sprintf('select * from %s where title = "%s" ',$tables['template'], sql_escape($title)));
8585
if(Sql_Affected_Rows()){
8686
$titleExists = true;
@@ -91,9 +91,9 @@ function getTemplateLinks($content)
9191
if($titleExists && !$id){
9292
$actionresult .= s('The title of the template exists.').'<br/>';
9393
$templateok = 0;
94-
9594
}
9695

96+
$content = disableJavascript($content);
9797
if (!empty($title) && strpos($content, '[CONTENT]') !== false) {
9898
$images = getTemplateImages($content);
9999

0 commit comments

Comments
 (0)