From f6691c138a9a0eb5e026a5b4108b425a96e1978f Mon Sep 17 00:00:00 2001
From: rabuzarus <rabuzarus@t-online.de>
Date: Wed, 13 Feb 2019 15:14:56 +0100
Subject: [PATCH 1/2] bugfix: linkPreview - remove s flag from regexp because
 FF don't support it

---
 view/js/linkPreview.js | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/view/js/linkPreview.js b/view/js/linkPreview.js
index 194ab6439..09583ae45 100644
--- a/view/js/linkPreview.js
+++ b/view/js/linkPreview.js
@@ -512,7 +512,7 @@
 		var getAttachmentData = function(content) {
 			var data = {};
 
-			var match = content.match(/(.*)\[attachment(.*?)\](.*?)\[\/attachment\](.*)/ism);
+			var match = content.match(/(.*)\[attachment(.*?)\](.*?)\[\/attachment\](.*)/im);
 			if (match === null || match.length < 5) {
 				return null;
 			}
@@ -521,12 +521,12 @@
 			data.text = trim(match[1]);
 
 			var type = '';
-			var matches = attributes.match(/type='(.*?)'/ism);
+			var matches = attributes.match(/type='(.*?)'/im);
 			if (matches !== null && typeof matches[1] !== 'undefined') {
 				type = matches[1].toLowerCase();
 			}
 
-			matches = attributes.match(/type="(.*?)"/ism);
+			matches = attributes.match(/type="(.*?)"/im);
 			if (matches !== null && typeof matches[1] !== 'undefined') {
 				type = matches[1].toLowerCase();
 			}
@@ -550,12 +550,12 @@
 
 			var url = '';
 
-			matches = attributes.match(/url='(.*?)'/ism);
+			matches = attributes.match(/url='(.*?)'/im);
 			if (matches !== null && typeof matches[1] !== 'undefined') {
 				url = matches[1].toLowerCase();
 			}
 
-			matches = attributes.match(/url="(.*?)"/ism);
+			matches = attributes.match(/url="(.*?)"/im);
 			if (matches !== null && typeof matches[1] !== 'undefined') {
 				url = matches[1].toLowerCase();
 			}
@@ -566,12 +566,12 @@
 
 			var title = '';
 
-			matches = attributes.match(/title='(.*?)'/ism);
+			matches = attributes.match(/title='(.*?)'/im);
 			if (matches !== null && typeof matches[1] !== 'undefined') {
 				title = matches[1].toLowerCase();
 			}
 
-			matches = attributes.match(/title="(.*?)"/ism);
+			matches = attributes.match(/title="(.*?)"/im);
 			if (matches !== null && typeof matches[1] !== 'undefined') {
 				title = matches[1].toLowerCase();
 			}
@@ -582,12 +582,12 @@
 
 			var image = '';
 
-			matches = attributes.match(/image='(.*?)'/ism);
+			matches = attributes.match(/image='(.*?)'/im);
 			if (matches !== null && typeof matches[1] !== 'undefined') {
 				image = matches[1].toLowerCase();
 			}
 
-			matches = attributes.match(/image="(.*?)"/ism);
+			matches = attributes.match(/image="(.*?)"/im);
 			if (matches !== null && typeof matches[1] !== 'undefined') {
 				image = matches[1].toLowerCase();
 			}
@@ -598,12 +598,12 @@
 
 			var preview = '';
 
-			matches = attributes.match(/preview='(.*?)'/ism);
+			matches = attributes.match(/preview='(.*?)'/im);
 			if (matches !== null && typeof matches[1] !== 'undefined') {
 				preview = matches[1].toLowerCase();
 			}
 
-			matches = attributes.match(/preview="(.*?)"/ism);
+			matches = attributes.match(/preview="(.*?)"/im);
 			if (matches !== null && typeof matches[1] !== 'undefined') {
 				preview = matches[1].toLowerCase();
 			}
@@ -630,7 +630,7 @@
 			if (attachmentData) {
 				reAddAttachment(attachmentData);
 				// Remove the attachment bbcode from the textarea.
-				var content = content.replace(/\[attachment.*\[\/attachment]/ism, '');
+				var content = content.replace(/\[attachment.*\[\/attachment]/im, '');
 				$('#' + selector).val(content);
 				$('#' + selector).focus();
 			}

From b7573a94ee4e598508cdc0198c4dc8b3fcfa9da6 Mon Sep 17 00:00:00 2001
From: rabuzarus <trebor@central-unit>
Date: Wed, 13 Feb 2019 22:26:56 +0100
Subject: [PATCH 2/2] linkPreview - workaround for mising 's' flag ins js regex

---
 view/js/linkPreview.js | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/view/js/linkPreview.js b/view/js/linkPreview.js
index 09583ae45..f0a5d741a 100644
--- a/view/js/linkPreview.js
+++ b/view/js/linkPreview.js
@@ -512,7 +512,7 @@
 		var getAttachmentData = function(content) {
 			var data = {};
 
-			var match = content.match(/(.*)\[attachment(.*?)\](.*?)\[\/attachment\](.*)/im);
+			var match = content.match(/([\s\S]*)\[attachment([\s\S]*?)\]([\s\S]*?)\[\/attachment\]([\s\S]*)/im);
 			if (match === null || match.length < 5) {
 				return null;
 			}
@@ -521,12 +521,12 @@
 			data.text = trim(match[1]);
 
 			var type = '';
-			var matches = attributes.match(/type='(.*?)'/im);
+			var matches = attributes.match(/type='([\s\S]*?)'/im);
 			if (matches !== null && typeof matches[1] !== 'undefined') {
 				type = matches[1].toLowerCase();
 			}
 
-			matches = attributes.match(/type="(.*?)"/im);
+			matches = attributes.match(/type="([\s\S]*?)"/im);
 			if (matches !== null && typeof matches[1] !== 'undefined') {
 				type = matches[1].toLowerCase();
 			}
@@ -550,12 +550,12 @@
 
 			var url = '';
 
-			matches = attributes.match(/url='(.*?)'/im);
+			matches = attributes.match(/url='([\s\S]*?)'/im);
 			if (matches !== null && typeof matches[1] !== 'undefined') {
 				url = matches[1].toLowerCase();
 			}
 
-			matches = attributes.match(/url="(.*?)"/im);
+			matches = attributes.match(/url="([\s\S]*?)"/im);
 			if (matches !== null && typeof matches[1] !== 'undefined') {
 				url = matches[1].toLowerCase();
 			}
@@ -566,12 +566,12 @@
 
 			var title = '';
 
-			matches = attributes.match(/title='(.*?)'/im);
+			matches = attributes.match(/title='([\s\S]*?)'/im);
 			if (matches !== null && typeof matches[1] !== 'undefined') {
 				title = matches[1].toLowerCase();
 			}
 
-			matches = attributes.match(/title="(.*?)"/im);
+			matches = attributes.match(/title="([\s\S]*?)"/im);
 			if (matches !== null && typeof matches[1] !== 'undefined') {
 				title = matches[1].toLowerCase();
 			}
@@ -582,12 +582,12 @@
 
 			var image = '';
 
-			matches = attributes.match(/image='(.*?)'/im);
+			matches = attributes.match(/image='([\s\S]*?)'/im);
 			if (matches !== null && typeof matches[1] !== 'undefined') {
 				image = matches[1].toLowerCase();
 			}
 
-			matches = attributes.match(/image="(.*?)"/im);
+			matches = attributes.match(/image="([\s\S]*?)"/im);
 			if (matches !== null && typeof matches[1] !== 'undefined') {
 				image = matches[1].toLowerCase();
 			}
@@ -598,12 +598,12 @@
 
 			var preview = '';
 
-			matches = attributes.match(/preview='(.*?)'/im);
+			matches = attributes.match(/preview='([\s\S]*?)'/im);
 			if (matches !== null && typeof matches[1] !== 'undefined') {
 				preview = matches[1].toLowerCase();
 			}
 
-			matches = attributes.match(/preview="(.*?)"/im);
+			matches = attributes.match(/preview="([\s\S]*?)"/im);
 			if (matches !== null && typeof matches[1] !== 'undefined') {
 				preview = matches[1].toLowerCase();
 			}
@@ -630,7 +630,7 @@
 			if (attachmentData) {
 				reAddAttachment(attachmentData);
 				// Remove the attachment bbcode from the textarea.
-				var content = content.replace(/\[attachment.*\[\/attachment]/im, '');
+				var content = content.replace(/\[attachment[\s\S]*\[\/attachment]/im, '');
 				$('#' + selector).val(content);
 				$('#' + selector).focus();
 			}