From 29bf72c9986462085da9632b59f534ee999f355d Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sun, 5 Mar 2023 23:03:50 +0900 Subject: [PATCH] Fix #2077 don't check hwpx files as XML --- common/framework/filters/FileContentFilter.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/framework/filters/FileContentFilter.php b/common/framework/filters/FileContentFilter.php index 690171bb2..986e6f208 100644 --- a/common/framework/filters/FileContentFilter.php +++ b/common/framework/filters/FileContentFilter.php @@ -41,6 +41,7 @@ class FileContentFilter $fp = fopen($file, 'rb'); $first4kb = fread($fp, 4096); $is_xml = preg_match('/<(?:\?xml|!DOCTYPE|html|head|body|meta|script|svg)\b/i', $first4kb); + $skip_xml = preg_match('/^(hwpx)$/', $ext); // Check SVG files. if (($ext === 'svg' || $is_xml) && !self::_checkSVG($fp, 0, $filesize)) @@ -71,7 +72,7 @@ class FileContentFilter } // Check HTML files. - if (($ext === 'html' || $ext === 'shtml' || $ext === 'xhtml' || $ext === 'phtml' || $is_xml) && !self::_checkHTML($fp, 0, $filesize)) + if (($ext === 'html' || $ext === 'shtml' || $ext === 'xhtml' || $ext === 'phtml' || ($is_xml && !$skip_xml)) && !self::_checkHTML($fp, 0, $filesize)) { fclose($fp); return false;