Allow media linking without https: or http: prefix on forum.

This commit is contained in:
flash 2023-03-09 16:18:52 +00:00
parent c7ed6ba511
commit 9983233184
4 changed files with 8 additions and 7 deletions

View file

@ -18,7 +18,8 @@ var MszEmbed = (function() {
const cleanUrl = target.dataset.mszEmbedUrl.replace(/ /, '%20');
if(cleanUrl.indexOf('https://') !== 0
&& cleanUrl.indexOf('http://') !== 0) {
&& cleanUrl.indexOf('http://') !== 0
&& cleanUrl.indexOf('//') !== 0) {
target.textContent = target.dataset.mszEmbedUrl;
continue;
}

View file

@ -6,11 +6,11 @@ use Misuzu\Parsers\BBCode\BBCodeTag;
final class AudioTag extends BBCodeTag {
public function parseText(string $text): string {
return preg_replace_callback(
'#\[audio\]((?:https?:\/\/).+?)\[/audio\]#',
'#\[audio\]((?:https?:)?\/\/.+?)\[/audio\]#',
function ($matches) {
$url = parse_url($matches[1]);
if(empty($url['scheme']) || !in_array(mb_strtolower($url['scheme']), ['http', 'https'], true))
if(!empty($url['scheme']) && !in_array(mb_strtolower($url['scheme']), ['http', 'https'], true))
return $matches[0];
return sprintf(

View file

@ -5,10 +5,10 @@ use Misuzu\Parsers\BBCode\BBCodeTag;
final class ImageTag extends BBCodeTag {
public function parseText(string $text): string {
return preg_replace_callback("/\[img\]((?:https?:\/\/).+?)\[\/img\]/", function ($matches) {
return preg_replace_callback("/\[img\]((?:https?:)?\/\/.+?)\[\/img\]/", function ($matches) {
$url = parse_url($matches[1]);
if(empty($url['scheme']) || !in_array(mb_strtolower($url['scheme']), ['http', 'https'], true))
if(!empty($url['scheme']) && !in_array(mb_strtolower($url['scheme']), ['http', 'https'], true))
return $matches[0];
// return sprintf(

View file

@ -6,11 +6,11 @@ use Misuzu\Parsers\BBCode\BBCodeTag;
final class VideoTag extends BBCodeTag {
public function parseText(string $text): string {
return preg_replace_callback(
'#\[video\]((?:https?:\/\/).+?)\[/video\]#',
'#\[video\]((?:https?:)?\/\/.+?)\[/video\]#',
function ($matches) {
$url = parse_url($matches[1]);
if(empty($url['scheme']) || !in_array(mb_strtolower($url['scheme']), ['http', 'https'], true))
if(!empty($url['scheme']) && !in_array(mb_strtolower($url['scheme']), ['http', 'https'], true))
return $matches[0];
return sprintf(