Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jappix/jappix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValérian Saliou <valerian@valeriansaliou.name>2015-08-07 14:27:54 +0300
committerValérian Saliou <valerian@valeriansaliou.name>2015-08-07 14:27:54 +0300
commit319eaf3f7e9224dfc5d172542c1f621aab94be46 (patch)
treedd8c1416f57a2e76887ead0e1a55db4d305a540f
parent4079e0f28feb3bd6d057b487151694981258278e (diff)
Disallow control characters
Signed-off-by: Valérian Saliou <valerian@valeriansaliou.name>
-rw-r--r--server/functions.php4
1 files changed, 3 insertions, 1 deletions
diff --git a/server/functions.php b/server/functions.php
index e38196f9..7706beca 100644
--- a/server/functions.php
+++ b/server/functions.php
@@ -1141,7 +1141,9 @@ function securityHTML() {
// Checks if a relative server path is safe
function isSafe($path) {
- return !preg_match('/^\//', $path) && !preg_match('/\.\.\//', $path);
+ return !preg_match('/^\//', $path) && # Absolute path (forbidden)
+ !preg_match('/\.\.\//', $path) && # Previous directory (forbidden)
+ !preg_match('/[[:cntrl:]]/', $path); # Control characters (forbidden)
}
// Checks if a relative server path is safe