Browse Source

Fix regression sharing links (#9303)

Fix https://github.com/FreshRSS/FreshRSS/issues/9302
Some links must be decoded before use.
Regression from https://github.com/FreshRSS/FreshRSS/pull/9146
Alexandre Alapetite 4 hours ago
parent
commit
74092a7fda
1 changed files with 5 additions and 3 deletions
  1. 5 3
      p/scripts/main.js

+ 5 - 3
p/scripts/main.js

@@ -1523,7 +1523,7 @@ function init_stream(stream) {
 		el = ev.target.closest('.item.share > button[data-type="clipboard"]');
 		if (el) { // Clipboard
 			if (navigator.clipboard) {
-				navigator.clipboard.writeText(el.dataset.url)
+				navigator.clipboard.writeText(decodeURIComponent(el.dataset.url))
 					.then(() => {
 						toggleClass(el, 'ok');
 					})
@@ -1534,7 +1534,7 @@ function init_stream(stream) {
 			} else {
 				// fallback, if navigator.clipboard is not available f.e. if access is not via https or localhost
 				const inputElement = document.createElement('input');
-				inputElement.value = el.dataset.url;
+				inputElement.value = decodeURIComponent(el.dataset.url);
 				document.body.appendChild(inputElement);
 				inputElement.select();
 				if (document.execCommand && document.execCommand('copy')) {
@@ -1552,7 +1552,7 @@ function init_stream(stream) {
 		el = ev.target.closest('.item.share > button[data-type="web-sharing-api"]');
 		if (el && navigator.share) {	// https://developer.mozilla.org/docs/Web/API/Navigator/share
 			const shareData = {
-				url: el.dataset.url,
+				url: decodeURIComponent(el.dataset.url),
 				title: decodeURI(el.dataset.title),
 			};
 			navigator.share(shareData);
@@ -1569,6 +1569,8 @@ function init_stream(stream) {
 		if (el) {	// Share by POST
 			const f = el.parentElement.querySelector('form');
 			f.disabled = false;
+			const input = f.querySelector('input');
+			input.value = decodeURIComponent(input.value);
 			f.submit();
 			return false;
 		}