Don't insert non-HTTP links to extension origin
| @@ -1068,7 +1068,7 @@ async function checkForUpdatesManual(abortSignal) { | ||
| 1068 | 1068 | try { |
| 1069 | 1069 | const data = await getExtensionVersion(externalId, abortSignal); |
| 1070 | 1070 | const extensionBlock = document.querySelector(`.extension_block[data-name="${externalId}"]`); |
| 1071 | 1071 | if (extensionBlock && data) { |
| 1072 | 1072 | if (data.isUpToDate === false) { |
| 1073 | 1073 | const buttonElement = extensionBlock.querySelector('.btn_update'); |
| 1074 | 1074 | if (buttonElement) { |
| @@ -1085,9 +1085,17 @@ async function checkForUpdatesManual(abortSignal) { | ||
| 1085 | 1085 | |
| 1086 | 1086 | const originLink = extensionBlock.querySelector('a'); |
| 1087 | 1087 | 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; | |
| 1089 | 1094 | originLink.target = '_blank'; |
| 1090 | 1095 | originLink.rel = 'noopener noreferrer'; |
| 1096 | + } catch (error) { | |
| 1097 | + console.log('Error setting origin link', originLink, error); | |
| 1098 | + } | |
| 1091 | 1099 | } |
| 1092 | 1100 | |
| 1093 | 1101 | const versionElement = extensionBlock.querySelector('.extension_version'); |