Merge pull request #856 from ethereum/fixFileChar

Check special char
pull/1/head
yann300 7 years ago committed by GitHub
commit 922fc5d8a3
  1. 7
      src/app.js
  2. 8
      src/app/files/file-explorer.js
  3. 5
      src/app/tabs/settings-tab.js
  4. 3
      src/lib/helper.js

@ -387,7 +387,12 @@ function run () {
// Add files received from remote instance (i.e. another browser-solidity)
function loadFiles (filesSet) {
for (var f in filesSet) {
filesProviders['browser'].set(helper.createNonClashingName(f, filesProviders['browser']), filesSet[f].content)
var name = helper.createNonClashingName(f, filesProviders['browser'])
if (helper.checkSpecialChars(name)) {
modalDialogCustom.alert('Special characters are not allowed')
return
}
filesProviders['browser'].set(name, filesSet[f].content)
}
fileManager.switchFile()
}

@ -7,6 +7,8 @@ var modalDialogCustom = require('../ui/modal-dialog-custom')
var EventManager = require('ethereum-remix').lib.EventManager
var helper = require('../../lib/helper')
var remix = require('ethereum-remix')
var styleGuide = remix.ui.styleGuide
var styles = styleGuide()
@ -141,6 +143,10 @@ function fileExplorer (appAPI, files) {
function loadFile () {
var fileReader = new FileReader()
fileReader.onload = function (event) {
if (helper.checkSpecialChars(name)) {
modalDialogCustom.alert('Special characters are not allowed')
return
}
var success = files.set(name, event.target.result)
if (!success) modalDialogCustom.alert('Failed to create file ' + name)
else events.trigger('focus', [name])
@ -232,7 +238,7 @@ function fileExplorer (appAPI, files) {
if (label.innerText === '') {
modalDialogCustom.alert('File name cannot be empty')
label.innerText = textUnderEdit
} else if (label.innerText.match(/(\/|:|\*|\?|"|<|>|\\|\||')/) !== null) {
} else if (helper.checkSpecialChars(label.innerText)) {
modalDialogCustom.alert('Special characters are not allowed')
label.innerText = textUnderEdit
} else if (!files.exists(newPath)) {

@ -8,6 +8,7 @@ var csjs = require('csjs-inject')
var remix = require('ethereum-remix')
var styleGuide = remix.ui.styleGuide
var styles = styleGuide()
var helper = require('../../lib/helper')
var css = csjs`
.settingsTabView {
@ -146,6 +147,10 @@ function loadVersion (version, queryParams, appAPI, el) {
url = location + 'soljson.js'
} else {
if (version.indexOf('soljson') !== 0 || helper.checkSpecialChars(version)) {
console.log('loading ' + version + ' not allowed')
return
}
url = 'https://ethereum.github.io/solc-bin/bin/' + version
}
var isFirefox = typeof InstallTrigger !== 'undefined'

@ -16,5 +16,8 @@ module.exports = {
counter = (counter | 0) + 1
}
return path + counter + '.sol'
},
checkSpecialChars (name) {
return name.match(/[/:*?"<>\\'|]/) != null
}
}

Loading…
Cancel
Save