Allow media linking without https: or http: prefix on forum.
This commit is contained in:
parent
c7ed6ba511
commit
9983233184
|
@ -18,7 +18,8 @@ var MszEmbed = (function() {
|
||||||
|
|
||||||
const cleanUrl = target.dataset.mszEmbedUrl.replace(/ /, '%20');
|
const cleanUrl = target.dataset.mszEmbedUrl.replace(/ /, '%20');
|
||||||
if(cleanUrl.indexOf('https://') !== 0
|
if(cleanUrl.indexOf('https://') !== 0
|
||||||
&& cleanUrl.indexOf('http://') !== 0) {
|
&& cleanUrl.indexOf('http://') !== 0
|
||||||
|
&& cleanUrl.indexOf('//') !== 0) {
|
||||||
target.textContent = target.dataset.mszEmbedUrl;
|
target.textContent = target.dataset.mszEmbedUrl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,11 @@ use Misuzu\Parsers\BBCode\BBCodeTag;
|
||||||
final class AudioTag extends BBCodeTag {
|
final class AudioTag extends BBCodeTag {
|
||||||
public function parseText(string $text): string {
|
public function parseText(string $text): string {
|
||||||
return preg_replace_callback(
|
return preg_replace_callback(
|
||||||
'#\[audio\]((?:https?:\/\/).+?)\[/audio\]#',
|
'#\[audio\]((?:https?:)?\/\/.+?)\[/audio\]#',
|
||||||
function ($matches) {
|
function ($matches) {
|
||||||
$url = parse_url($matches[1]);
|
$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 $matches[0];
|
||||||
|
|
||||||
return sprintf(
|
return sprintf(
|
||||||
|
|
|
@ -5,10 +5,10 @@ use Misuzu\Parsers\BBCode\BBCodeTag;
|
||||||
|
|
||||||
final class ImageTag extends BBCodeTag {
|
final class ImageTag extends BBCodeTag {
|
||||||
public function parseText(string $text): string {
|
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]);
|
$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 $matches[0];
|
||||||
|
|
||||||
// return sprintf(
|
// return sprintf(
|
||||||
|
|
|
@ -6,11 +6,11 @@ use Misuzu\Parsers\BBCode\BBCodeTag;
|
||||||
final class VideoTag extends BBCodeTag {
|
final class VideoTag extends BBCodeTag {
|
||||||
public function parseText(string $text): string {
|
public function parseText(string $text): string {
|
||||||
return preg_replace_callback(
|
return preg_replace_callback(
|
||||||
'#\[video\]((?:https?:\/\/).+?)\[/video\]#',
|
'#\[video\]((?:https?:)?\/\/.+?)\[/video\]#',
|
||||||
function ($matches) {
|
function ($matches) {
|
||||||
$url = parse_url($matches[1]);
|
$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 $matches[0];
|
||||||
|
|
||||||
return sprintf(
|
return sprintf(
|
||||||
|
|
Loading…
Reference in a new issue