diff --git a/tests/php/test_monitor_edit_value_escape.php b/tests/php/test_monitor_edit_value_escape.php new file mode 100644 index 0000000000..273d9f8e46 --- /dev/null +++ b/tests/php/test_monitor_edit_value_escape.php @@ -0,0 +1,74 @@ + $line) { + if (strpos($line, $name) === false) { + continue; + } + if (!preg_match_all('/value="<\?php echo (.*?)\s*\?>/', $line, $values)) { + continue; + } + foreach ($values[1] as $expr) { + $matches[] = array('line' => $offset + 1, 'expr' => trim($expr)); + } + } + + check("$field: a value=\"...\" input is found to scan", count($matches) > 0); + + foreach ($matches as $match) { + $expr = $match['expr']; + $escaped = strpos($expr, 'validHtmlStr(') === 0 + || strpos($expr, 'htmlspecialchars(') === 0; + check("$field: the value at monitor.php:{$match['line']} is escaped", $escaped); + } +} + +echo "\n$tests tests, $failures failures\n"; +exit($failures ? 1 : 0); diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index 1e8b865666..374928c200 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -1182,7 +1182,7 @@ echo htmlSelect('newMonitor[Decoder]', $decoders, $monitor->Decoder());