From 6e929934c59cd922bca41edb56b62b6032114a47 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 20 Dec 2016 15:14:43 -0500 Subject: [PATCH] proxy: Simplify url extension extraction --- mod/proxy.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/mod/proxy.php b/mod/proxy.php index 57c722739..46d77726c 100644 --- a/mod/proxy.php +++ b/mod/proxy.php @@ -281,15 +281,8 @@ function proxy_url($url, $writemode = false, $size = '') { $longpath .= '/' . strtr(base64_encode($url), '+/', '-_'); - // Extract the URL extension, disregarding GET parameters starting with ? - $question_mark_pos = strpos($url, '?'); - if ($question_mark_pos === false) { - $question_mark_pos = strlen($url); - } - $dot_pos = strrpos($url, '.', $question_mark_pos - strlen($url)); - if ($dot_pos !== false) { - $extension = strtolower(substr($url, $dot_pos + 1, $question_mark_pos - ($dot_pos + 1))); - } + // Extract the URL extension + $extension = pathinfo(parse_url($url, PHP_URL_PATH), PATHINFO_EXTENSION); $extensions = array('jpg', 'jpeg', 'gif', 'png'); if (in_array($extension, $extensions)) {