diff --git a/add-on/_locales/en/messages.json b/add-on/_locales/en/messages.json index c97e29ebf..2d6730b9e 100644 --- a/add-on/_locales/en/messages.json +++ b/add-on/_locales/en/messages.json @@ -239,6 +239,10 @@ "message": "URL of preferred HTTP2IPFS Gateway", "description": "An option description on the Preferences screen (option_customGatewayUrl_description)" }, + "option_customGatewayUrl_warning": { + "message": "IPFS content will be blocked from loading on HTTPS websites unless your gateway URL starts with “http://127.0.0.1”, “http://[::1]” or “https://”", + "description": "A warning on the Preferences screen, displayed when URL does not belong to Secure Context (option_customGatewayUrl_warning)" + }, "option_useCustomGateway_title": { "message": "Use Custom Gateway", "description": "An option title on the Preferences screen (option_useCustomGateway_title)" diff --git a/add-on/src/options/forms/gateways-form.js b/add-on/src/options/forms/gateways-form.js index 56c211186..dddc87a41 100644 --- a/add-on/src/options/forms/gateways-form.js +++ b/add-on/src/options/forms/gateways-form.js @@ -5,6 +5,10 @@ const browser = require('webextension-polyfill') const html = require('choo/html') const { normalizeGatewayURL } = require('../../lib/options') +// Warn about mixed content issues when changing the gateway +// https://github.com/ipfs-shipyard/ipfs-companion/issues/648 +const secureContextUrl = /^https:\/\/|^http:\/\/127.0.0.1|^http:\/\/\[::1\]/ + function gatewaysForm ({ ipfsNodeType, customGatewayUrl, @@ -15,6 +19,7 @@ function gatewaysForm ({ const onCustomGatewayUrlChange = onOptionChange('customGatewayUrl', normalizeGatewayURL) const onUseCustomGatewayChange = onOptionChange('useCustomGateway') const onPublicGatewayUrlChange = onOptionChange('publicGatewayUrl', normalizeGatewayURL) + const mixedContentWarning = !secureContextUrl.test(customGatewayUrl) return html`