Archived
1
0

Fix regexp to truncate media extensińs to 5 chars.

See 4ee1066b89
and https://gist.github.com/mmitch/5b466e6f89efc6dccd7dce2cf7d72742

Thanks to @mmitch!

Signed-off-by: Thomas Hochstein <thh@inter.net>
This commit is contained in:
Thomas Hochstein
2020-04-20 08:44:30 +02:00
parent b2b1de66b6
commit c694fb0f45
+2 -2
View File
@@ -2041,11 +2041,11 @@ 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)
# 1) (\.[^./\\\]{5}) up to five chars after a dot are captured
# 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);
$var = preg_replace('@(\.[^./\\\]{5})[^./\\\]+$@', '$1', $var);
return $var;
}