Archived
1
0

Truncate extension of media items to 5 chars.

That's the max length of the extensin
database field.

Fixes #609.

Signed-off-by: Thomas Hochstein <thh@inter.net>
This commit is contained in:
Thomas Hochstein
2020-03-25 21:46:05 +01:00
parent 1b6840d98e
commit 4ee1066b89
+7
View File
@@ -2040,6 +2040,13 @@ function serendipity_uploadSecure($var, $strip_paths = true, $append_slash = fal
}
}
# truncate extensions to 5 chars
# 1) (\.[^.]{0,5}+) five chars after a dot are captured (possessively)
# 2) expression matches only if followed by anything that is no dot
# and has no / or \ at the end
# 3) if epxression matches, everything after the capture group is deleted
$var = preg_replace('@(\.[^.]{0,5}+)[^./\\\]*[^/\\\]{1,1}?$@', '$1', $var);
return $var;
}