mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Add additional rpcUrl verification (#7436)
* Add additional url verification * Add commas * Address PR feedback * Use URL over URI * Update key in other languages * Add stateKey check * Split validateUrl into two separate methods * Remove unused variable * Add isValidWhenAppended method
This commit is contained in:
parent
9d03865274
commit
346c1f2622
@ -1344,7 +1344,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "የዘመነ $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URIs አግባብነት ያለው የ HTTP/HTTPS ቅድመ ቅጥያ ይፈልጋል።"
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1340,7 +1340,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "تم تحديث $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "تتطلب الروابط بادئة HTTP/HTTPS مناسبة."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1343,7 +1343,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Актуализирано $1 "
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI изискват съответния HTTP / HTTPS префикс."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1347,7 +1347,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "আপডেট করা $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI গুলির যথাযথ HTTP/HTTPS প্রেফিক্সের প্রয়োজন।"
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1316,7 +1316,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Actualitzat $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "Els URIs requereixen el prefix HTTP/HTTPS apropiat."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -529,7 +529,7 @@
|
||||
"unknownNetwork": {
|
||||
"message": "Neznámá soukromá síť"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI vyžadují korektní HTTP/HTTPS prefix."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1313,7 +1313,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Opdaterede $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "Links kræver det rette HTTP/HTTPS-præfix."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1304,7 +1304,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "$1 aktualisiert"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URIs benötigen die korrekten HTTP/HTTPS Präfixe."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1341,7 +1341,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Ενημερώθηκε το $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "Τα URI απαιτούν το κατάλληλο πρόθεμα HTTP/HTTPS."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1474,8 +1474,11 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Updated $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"message": "URIs require the appropriate HTTP/HTTPS prefix."
|
||||
"urlErrorMsg": {
|
||||
"message": "URLs require the appropriate HTTP/HTTPS prefix."
|
||||
},
|
||||
"urlExistsErrorMsg": {
|
||||
"message": "URL is already present in existing list of networks"
|
||||
},
|
||||
"usedByClients": {
|
||||
"message": "Used by a variety of different clients"
|
||||
|
@ -1091,7 +1091,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Actualizado $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI necesita el prefijo HTTP/HTTPS apropiado"
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1326,7 +1326,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Actualización: $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "Los URI deben tener el prefijo HTTP/HTTPS apropiado."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1337,7 +1337,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Värskendatud $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI-d nõuavad sobivat HTTP/HTTPS-i prefiksit."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1347,7 +1347,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "بروزرسانی شد 1$1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URl ها نیازمند پیشوند مناسب HTTP/HTTPS اند."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1344,7 +1344,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "$1 päivitetty"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI:t vaativat asianmukaisen HTTP/HTTPS-etuliitteen."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1235,7 +1235,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Na-update ang $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "Kinakailangan ng mga URI ang naaangkop na HTTP/HTTPS prefix."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1308,7 +1308,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Mis à jour $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "Les URLs requièrent un préfixe HTTP/HTTPS approprié."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1341,7 +1341,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "עודכן $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "כתובות URI דורשות את קידומת HTTP/HTTPS המתאימה."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1341,7 +1341,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "$1 अपडेट किया गया"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI को उपयुक्त HTTP/HTTPS प्रीफ़िक्स की आवश्यकता होती है।"
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -491,7 +491,7 @@
|
||||
"unknownNetwork": {
|
||||
"message": "अज्ञात निजी नेटवर्क"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI-यूआरआई को उपयुक्त HTTP / HTTPS उपसर्ग की आवश्यकता होती है।"
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1337,7 +1337,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Ažurirano $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI-jevima se zahtijeva prikladan prefiks HTTP/HTTPS."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -851,7 +851,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Mete ajou $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URIs mande pou apwopriye prefiks HTTP / HTTPS a."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1337,7 +1337,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "$1 frissítve"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "Az URI-hez szükség van a megfelelő HTTP/HTTPS előtagra."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1316,7 +1316,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Diperbarui $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI memerlukan awalan HTTP/HTTPS yang sesuai."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1307,7 +1307,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Aggiornata $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "Gli URI richiedono un prefisso HTTP/HTTPS."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1347,7 +1347,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "$1 ನವೀಕರಿಸಲಾಗಿದೆ"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI ಗಳಿಗೆ ಸೂಕ್ತವಾದ HTTP/HTTPS ಪೂರ್ವಪ್ರತ್ಯಯದ ಅಗತ್ಯವಿದೆ."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1338,7 +1338,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "$1에 업데이트 됨"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI는 HTTP/HTTPS로 시작해야 합니다."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1347,7 +1347,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Atnaujinta $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI reikia atitinkamo HTTP/HTTPS priešdėlio."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1343,7 +1343,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Atjaunināts $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI jāsākas ar atbilstošo HTTP/HTTPS priedēkli."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1315,7 +1315,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Dikemaskini $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI memerlukan awalan HTTP/HTTPS yang sesuai."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -478,7 +478,7 @@
|
||||
"unknownNetwork": {
|
||||
"message": "Onbekend privénetwerk"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "Voor URI's is het juiste HTTP / HTTPS-voorvoegsel vereist."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1319,7 +1319,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Oppdatert $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI-er krever det aktuelle HTTP/HTTPS-prefikset."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1332,7 +1332,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Zaktualizowano $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI wymaga prawidłowego prefiksu HTTP/HTTPS."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -488,7 +488,7 @@
|
||||
"unknownNetwork": {
|
||||
"message": "Rede Privada Desconhecida"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "Links requerem o prefixo HTTP/HTTPS apropriado."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1326,7 +1326,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "$1 atualizado"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URIs exigem o devido prefixo HTTP/HTTPS."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1328,7 +1328,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Actualizat $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URL necesită prefixul potrivit HTTP/HTTPS."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -542,7 +542,7 @@
|
||||
"unknownNetwork": {
|
||||
"message": "Неизвестная частная сеть"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "Для URI требуется соответствующий префикс HTTP/HTTPS."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1301,7 +1301,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Aktualizované $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI vyžadují korektní HTTP/HTTPS prefix."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1329,7 +1329,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Posodobljeno $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI zahtevajo ustrezno HTTP/HTTPS predpono."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1332,7 +1332,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Ažuriran $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI-ovi zahtevaju odgovarajući prefiks HTTP / HTTPS."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1322,7 +1322,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Uppdaterat $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI:er kräver lämpligt HTTP/HTTPS-prefix."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1325,7 +1325,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Imesasishwa $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI huhitaji kiambishi sahihi cha HTTP/HTTPS."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -554,7 +554,7 @@
|
||||
"unknownNetwork": {
|
||||
"message": "அறியப்படாத தனியார் நெட்வொர்க்"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI கள் சரியான HTTP / HTTPS முன்னொட்டு தேவை."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -656,7 +656,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "อัปเดต $1 แล้ว"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URI ต้องมีคำนำหน้าเป็น HTTP หรือ HTTPS"
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -547,7 +547,7 @@
|
||||
"unknownNetwork": {
|
||||
"message": "Bilinmeyen özel ağ"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URIler için HTTP/HTTPS öneki gerekmektedir."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1347,7 +1347,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "Оновлено $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URIs вимагають відповідного префікса HTTP/HTTPS."
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -1320,7 +1320,7 @@
|
||||
"updatedWithDate": {
|
||||
"message": "更新時間 $1"
|
||||
},
|
||||
"uriErrorMsg": {
|
||||
"urlErrorMsg": {
|
||||
"message": "URIs 需要加入適當的 HTTP/HTTPS 前綴字"
|
||||
},
|
||||
"usedByClients": {
|
||||
|
@ -24,6 +24,7 @@ export default class NetworkForm extends PureComponent {
|
||||
isCurrentRpcTarget: PropTypes.bool,
|
||||
blockExplorerUrl: PropTypes.string,
|
||||
rpcPrefs: PropTypes.object,
|
||||
rpcUrls: PropTypes.array,
|
||||
}
|
||||
|
||||
state = {
|
||||
@ -211,16 +212,28 @@ export default class NetworkForm extends PureComponent {
|
||||
)
|
||||
}
|
||||
|
||||
validateUrl = (url, stateKey) => {
|
||||
const invalidUrlErrorMsg = stateKey === 'rpcUrl' ? 'invalidRPC' : 'invalidBlockExplorerURL'
|
||||
isValidWhenAppended = url => {
|
||||
const appendedRpc = `http://${url}`
|
||||
return validUrl.isWebUri(appendedRpc) && !url.match(/^https?:\/\/$/)
|
||||
}
|
||||
|
||||
if (validUrl.isWebUri(url) || (stateKey === 'blockExplorerUrl' && url === '')) {
|
||||
this.setErrorTo(stateKey, '')
|
||||
validateBlockExplorerURL = (url, stateKey) => {
|
||||
if (!validUrl.isWebUri(url) && url !== '') {
|
||||
this.setErrorTo(stateKey, this.context.t(this.isValidWhenAppended(url) ? 'urlErrorMsg' : 'invalidBlockExplorerURL'))
|
||||
} else {
|
||||
const appendedRpc = `http://${url}`
|
||||
const validWhenAppended = validUrl.isWebUri(appendedRpc) && !url.match(/^https?:\/\/$/)
|
||||
this.setErrorTo(stateKey, '')
|
||||
}
|
||||
}
|
||||
|
||||
this.setErrorTo(stateKey, this.context.t(validWhenAppended ? 'uriErrorMsg' : invalidUrlErrorMsg))
|
||||
validateUrlRpcUrl = (url, stateKey) => {
|
||||
const { rpcUrls } = this.props
|
||||
|
||||
if (!validUrl.isWebUri(url) && url !== '') {
|
||||
this.setErrorTo(stateKey, this.context.t(this.isValidWhenAppended(url) ? 'urlErrorMsg' : 'invalidRPC'))
|
||||
} else if (rpcUrls.includes(url)) {
|
||||
this.setErrorTo(stateKey, this.context.t('urlExistsErrorMsg'))
|
||||
} else {
|
||||
this.setErrorTo(stateKey, '')
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,7 +267,7 @@ export default class NetworkForm extends PureComponent {
|
||||
{this.renderFormTextField(
|
||||
'rpcUrl',
|
||||
'rpc-url',
|
||||
this.setStateWithValue('rpcUrl', this.validateUrl),
|
||||
this.setStateWithValue('rpcUrl', this.validateUrlRpcUrl),
|
||||
rpcUrl,
|
||||
)}
|
||||
{this.renderFormTextField(
|
||||
@ -274,7 +287,7 @@ export default class NetworkForm extends PureComponent {
|
||||
{this.renderFormTextField(
|
||||
'blockExplorerUrl',
|
||||
'block-explorer-url',
|
||||
this.setStateWithValue('blockExplorerUrl', this.validateUrl),
|
||||
this.setStateWithValue('blockExplorerUrl', this.validateBlockExplorerURL),
|
||||
blockExplorerUrl,
|
||||
'optionalBlockExplorerUrl',
|
||||
)}
|
||||
|
@ -20,7 +20,7 @@ export default class NetworksTab extends PureComponent {
|
||||
location: PropTypes.object.isRequired,
|
||||
networkIsSelected: PropTypes.bool,
|
||||
networksTabIsInAddMode: PropTypes.bool,
|
||||
networksToRender: PropTypes.array.isRequired,
|
||||
networksToRender: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
selectedNetwork: PropTypes.object,
|
||||
setNetworksTabAddMode: PropTypes.func.isRequired,
|
||||
setRpcTarget: PropTypes.func.isRequired,
|
||||
@ -177,6 +177,7 @@ export default class NetworksTab extends PureComponent {
|
||||
editRpc,
|
||||
networkDefaultedToProvider,
|
||||
providerUrl,
|
||||
networksToRender,
|
||||
} = this.props
|
||||
|
||||
const envIsPopup = getEnvironmentType() === ENVIRONMENT_TYPE_POPUP
|
||||
@ -189,6 +190,7 @@ export default class NetworksTab extends PureComponent {
|
||||
shouldRenderNetworkForm
|
||||
? (
|
||||
<NetworkForm
|
||||
rpcUrls={networksToRender.map(network => network.rpcUrl)}
|
||||
setRpcTarget={setRpcTarget}
|
||||
editRpc={editRpc}
|
||||
networkName={label || labelKey && t(labelKey) || ''}
|
||||
|
Loading…
Reference in New Issue
Block a user