Don't insert non-HTTP links to extension origin

df8e0ba9234715d5d274613cbef909c22a2632c5

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +10 -2Showing whitespace changes
public/scripts/extensions.js+10 -2
@@ -1068,7 +1068,7 @@ async function checkForUpdatesManual(abortSignal) {
10681068 try {
10691069 const data = await getExtensionVersion(externalId, abortSignal);
10701070 const extensionBlock = document.querySelector(`.extension_block[data-name="${externalId}"]`);
10711071 if (extensionBlock && data) {
10721072 if (data.isUpToDate === false) {
10731073 const buttonElement = extensionBlock.querySelector('.btn_update');
10741074 if (buttonElement) {
@@ -1085,9 +1085,17 @@ async function checkForUpdatesManual(abortSignal) {
10851085
10861086 const originLink = extensionBlock.querySelector('a');
10871087 if (originLink) {
1088- originLink.href = origin;
1088+ try {
1089+ const url = new URL(origin);
1090+ if (!['https:', 'http:'].includes(url.protocol)) {
1091+ throw new Error('Invalid protocol');
1092+ }
1093+ originLink.href = url.href;
10891094 originLink.target = '_blank';
10901095 originLink.rel = 'noopener noreferrer';
1096+ } catch (error) {
1097+ console.log('Error setting origin link', originLink, error);
1098+ }
10911099 }
10921100
10931101 const versionElement = extensionBlock.querySelector('.extension_version');