From f687d51f9aa2ea7617d7c88939193b1d5d70ea63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Sat, 10 Apr 2021 22:16:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E6=94=BE=E5=AE=BD?= =?UTF-8?q?=E5=AA=92=E4=BD=93=E6=92=AD=E6=94=BE=E9=99=90=E5=88=B6=EF=BC=8C?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=9F=BA=E4=BA=8E=E7=99=BE=E5=88=86=E6=AF=94?= =?UTF-8?q?=E7=9A=84=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- upload/source/function/function_discuzcode.php | 18 ++++++++++++++---- upload/source/function/function_followcode.php | 2 +- .../include/portalcp/portalcp_article.php | 5 ++--- .../source/plugin/mobile/discuzcode.func.php | 2 +- .../plugin/qqconnect/connect/connect_feed.php | 4 ++-- upload/static/js/common.js | 14 ++++++++------ 6 files changed, 28 insertions(+), 17 deletions(-) diff --git a/upload/source/function/function_discuzcode.php b/upload/source/function/function_discuzcode.php index 878fd54d8..f5ec04500 100644 --- a/upload/source/function/function_discuzcode.php +++ b/upload/source/function/function_discuzcode.php @@ -187,7 +187,7 @@ function discuzcode($message, $smileyoff = false, $bbcodeoff = false, $htmlon = } if(!defined('IN_MOBILE') || !in_array(constant('IN_MOBILE'), array('1', '3', '4'))) { if(strpos($msglower, '[/media]') !== FALSE) { - $message = preg_replace_callback("/\[media=([\w,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is", $allowmediacode ? 'discuzcode_callback_parsemedia_12' : 'discuzcode_callback_bbcodeurl_2', $message); + $message = preg_replace_callback("/\[media=([\w%,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is", $allowmediacode ? 'discuzcode_callback_parsemedia_12' : 'discuzcode_callback_bbcodeurl_2', $message); } if(strpos($msglower, '[/audio]') !== FALSE) { $message = preg_replace_callback("/\[audio(=1)*\]\s*([^\[\<\r\n]+?)\s*\[\/audio\]/is", $allowmediacode ? 'discuzcode_callback_parseaudio_2' : 'discuzcode_callback_bbcodeurl_2', $message); @@ -197,7 +197,7 @@ function discuzcode($message, $smileyoff = false, $bbcodeoff = false, $htmlon = } } else { if(strpos($msglower, '[/media]') !== FALSE) { - $message = preg_replace("/\[media=([\w,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is", "[media]\\2[/media]", $message); + $message = preg_replace("/\[media=([\w%,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is", "[media]\\2[/media]", $message); } if(strpos($msglower, '[/audio]') !== FALSE) { $message = preg_replace("/\[audio(=1)*\]\s*([^\[\<\r\n]+?)\s*\[\/audio\]/is", "[media]\\2[/media]", $message); @@ -452,8 +452,18 @@ function parseaudio($url, $width = 400) { function parsemedia($params, $url) { $params = explode(',', $params); - $width = intval($params[1]) > 800 ? 800 : intval($params[1]); - $height = intval($params[2]) > 600 ? 600 : intval($params[2]); + + if(preg_match('/^(100|[0-9]{1,2})%$/', $params[1], $matches)) { + $width = $matches[1] . '%'; + } else { + $width = ($params[1] > 0 && $params[1] < 8192) ? intval($params[1]) : 800; + } + + if(preg_match('/^(100|[0-9]{1,2})%$/', $params[2], $matches)) { + $height = $matches[2] . '%'; + } else { + $height = ($params[2] > 0 && $params[2] < 4096) ? intval($params[2]) : 600; + } $url = addslashes($url); if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'https:', 'ftp://', 'rtsp:/', 'mms://')) && !preg_match('/^static\//', $url) && !preg_match('/^data\//', $url)) { diff --git a/upload/source/function/function_followcode.php b/upload/source/function/function_followcode.php index d850f42c8..165ce8d7c 100644 --- a/upload/source/function/function_followcode.php +++ b/upload/source/function/function_followcode.php @@ -114,7 +114,7 @@ function followcode($message, $tid = 0, $pid = 0, $length = 0, $allowimg = true) } if(strpos($msglower, '[/media]') !== FALSE) { - $message = preg_replace_callback("/\[media=([\w,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is", 'followcode_callback_fparsemedia_12', $message); + $message = preg_replace_callback("/\[media=([\w%,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is", 'followcode_callback_fparsemedia_12', $message); } if(strpos($msglower, '[/audio]') !== FALSE) { $message = preg_replace_callback("/\[audio(=1)*\]\s*([^\[\<\r\n]+?)\s*\[\/audio\]/is", 'followcode_callback_fparseaudio_2', $message); diff --git a/upload/source/include/portalcp/portalcp_article.php b/upload/source/include/portalcp/portalcp_article.php index 33fba63de..ea49643aa 100644 --- a/upload/source/include/portalcp/portalcp_article.php +++ b/upload/source/include/portalcp/portalcp_article.php @@ -675,7 +675,7 @@ function portalcp_get_postmessage($post, $getauthorall = '') { $msglower = strtolower($post['message']); if(strpos($msglower, '[/media]') !== FALSE) { - $post['message'] = preg_replace_callback("/\[media=([\w,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is", 'portalcp_get_postmessage_callback_parsearticlemedia_12', $post['message']); + $post['message'] = preg_replace_callback("/\[media=([\w%,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is", 'portalcp_get_postmessage_callback_parsearticlemedia_12', $post['message']); } if(strpos($msglower, '[/audio]') !== FALSE) { $post['message'] = preg_replace_callback("/\[audio(=1)*\]\s*([^\[\<\r\n]+?)\s*\[\/audio\]/is", 'portalcp_get_postmessage_callback_parsearticlemedia_2', $post['message']); @@ -728,8 +728,7 @@ function parsearticlemedia($params, $url) { global $_G; $params = explode(',', $params); - $width = intval($params[1]) > 800 ? 800 : intval($params[1]); - $height = intval($params[2]) > 600 ? 600 : intval($params[2]); + $url = addslashes($url); if($flv = parseflv($url, 0, 0)) { if(!empty($flv) && preg_match("/\.flv$/i", $flv['flv'])) { diff --git a/upload/source/plugin/mobile/discuzcode.func.php b/upload/source/plugin/mobile/discuzcode.func.php index 80e3a4b7c..6554a7d32 100644 --- a/upload/source/plugin/mobile/discuzcode.func.php +++ b/upload/source/plugin/mobile/discuzcode.func.php @@ -120,7 +120,7 @@ function mobile_discuzcode($param) { } } if(strpos($msglower, '[/media]') !== FALSE) { - $message = preg_replace_callback("/\[media=([\w,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is", 'mobile_discuzcode_callback_bbcodeurl_media2', $message); + $message = preg_replace_callback("/\[media=([\w%,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is", 'mobile_discuzcode_callback_bbcodeurl_media2', $message); } if(strpos($msglower, '[/audio]') !== FALSE) { $message = preg_replace_callback("/\[audio(=1)*\]\s*([^\[\<\r\n]+?)\s*\[\/audio\]/is", 'mobile_discuzcode_callback_bbcodeurl_href2', $message); diff --git a/upload/source/plugin/qqconnect/connect/connect_feed.php b/upload/source/plugin/qqconnect/connect/connect_feed.php index badb596b7..78d8b53b2 100644 --- a/upload/source/plugin/qqconnect/connect/connect_feed.php +++ b/upload/source/plugin/qqconnect/connect/connect_feed.php @@ -53,7 +53,7 @@ if ($op == 'new') { $post['message'] = preg_replace('/\[quote\].*\[\/quote\](\r\n|\n|\r){0,}/is', '', $post['message']); } if(strpos($msglower, '[/media]') !== FALSE) { - $post['message'] = preg_replace("/\[media=([\w,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is", '', $post['message']); + $post['message'] = preg_replace("/\[media=([\w%,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is", '', $post['message']); } if(strpos($msglower, '[/flash]') !== FALSE) { $post['message'] = preg_replace("/\[flash(=(\d+),(\d+))?\]\s*([^\[\<\r\n]+?)\s*\[\/flash\]/is", '', $post['message']); @@ -217,7 +217,7 @@ if ($op == 'new') { $post['message'] = preg_replace('/\[quote\].*\[\/quote\](\r\n|\n|\r){0,}/is', '', $post['message']); } if(strpos($msglower, '[/media]') !== FALSE) { - $post['message'] = preg_replace("/\[media=([\w,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is", '', $post['message']); + $post['message'] = preg_replace("/\[media=([\w%,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is", '', $post['message']); } if(strpos($msglower, '[/flash]') !== FALSE) { $post['message'] = preg_replace("/\[flash(=(\d+),(\d+))?\]\s*([^\[\<\r\n]+?)\s*\[\/flash\]/is", '', $post['message']); diff --git a/upload/static/js/common.js b/upload/static/js/common.js index 436bd6fbf..5cc8f9523 100644 --- a/upload/static/js/common.js +++ b/upload/static/js/common.js @@ -1999,13 +1999,15 @@ function detectHtml5Support() { function detectPlayer(randomid, ext, src, width, height) { var h5_support = new Array('aac', 'flac', 'mp3', 'm4a', 'wav', 'flv', 'mp4', 'm4v', '3gp', 'ogv', 'ogg', 'weba', 'webm'); var trad_support = new Array('mp3', 'wma', 'mid', 'wav', 'ra', 'ram', 'rm', 'rmvb', 'swf', 'asf', 'asx', 'wmv', 'avi', 'mpg', 'mpeg', 'mov'); + width = width.indexOf("%") == -1 ? width + 'px' : width; + height = height.indexOf("%") == -1 ? height + 'px' : height; if (in_array(ext, h5_support) && detectHtml5Support()) { html5Player(randomid, ext, src, width, height); } else if (in_array(ext, trad_support)) { tradionalPlayer(randomid, ext, src, width, height); } else { - $(randomid).style.width = width + 'px'; - $(randomid).style.height = height + 'px'; + $(randomid).style.width = width; + $(randomid).style.height = height; } } @@ -2044,8 +2046,8 @@ function tradionalPlayer(randomid, ext, src, width, height) { default: break; } - $(randomid).style.width = width + 'px'; - $(randomid).style.height = height + 'px'; + $(randomid).style.width = width; + $(randomid).style.height = height; $(randomid + '_container').innerHTML = html; } @@ -2076,8 +2078,8 @@ function html5Player(randomid, ext, src, width, height) { default: break; } - $(randomid).style.width = width + 'px'; - $(randomid).style.height = height + 'px'; + $(randomid).style.width = width; + $(randomid).style.height = height; } function html5APlayer(randomid, ext, src, width, height) { -- Gitee