Make "disablewebsecurity" optional

This commit is contained in:
Yuya Ochiai
2016-04-17 23:07:17 +09:00
parent 2eae1d42d2
commit e1b008a3e0
3 changed files with 14 additions and 7 deletions

View File

@@ -247,8 +247,10 @@ var MattermostView = React.createClass({
var webview = ReactDOM.findDOMNode(this.refs.webview); var webview = ReactDOM.findDOMNode(this.refs.webview);
// This option disables the same-origin policy and allows js/css/plugins not only content like images. // This option disables the same-origin policy and allows js/css/plugins not only content like images.
// So this should not be enabled. if (config.disablewebsecurity === true) {
webview.setAttribute('disablewebsecurity', true); // webview.setAttribute('disablewebsecurity', false) disables websecurity. (electron's bug?)
webview.setAttribute('disablewebsecurity', true);
}
webview.addEventListener('did-fail-load', function(e) { webview.addEventListener('did-fail-load', function(e) {
console.log(thisObj.props.name, 'webview did-fail-load', e); console.log(thisObj.props.name, 'webview did-fail-load', e);

View File

@@ -28,11 +28,7 @@ var SettingsPage = React.createClass({
} catch (e) { } catch (e) {
config = settings.loadDefault(); config = settings.loadDefault();
} }
return { return config;
teams: config.teams,
hideMenuBar: config.hideMenuBar,
showTrayIcon: config.showTrayIcon
};
}, },
handleTeamsChange: function(teams) { handleTeamsChange: function(teams) {
this.setState({ this.setState({
@@ -44,6 +40,7 @@ var SettingsPage = React.createClass({
teams: this.state.teams, teams: this.state.teams,
hideMenuBar: this.state.hideMenuBar, hideMenuBar: this.state.hideMenuBar,
showTrayIcon: this.state.showTrayIcon, showTrayIcon: this.state.showTrayIcon,
disablewebsecurity: this.state.disablewebsecurity,
version: settings.version version: settings.version
}; };
settings.writeFileSync(this.props.configFile, config); settings.writeFileSync(this.props.configFile, config);
@@ -57,6 +54,11 @@ var SettingsPage = React.createClass({
handleCancel: function() { handleCancel: function() {
backToIndex(); backToIndex();
}, },
handleChangeDisableWebSecurity: function() {
this.setState({
disablewebsecurity: this.refs.disablewebsecurity.getChecked()
});
},
handleChangeHideMenuBar: function() { handleChangeHideMenuBar: function() {
this.setState({ this.setState({
hideMenuBar: this.refs.hideMenuBar.getChecked() hideMenuBar: this.refs.hideMenuBar.getChecked()
@@ -85,6 +87,8 @@ var SettingsPage = React.createClass({
options.push(<Input ref="showTrayIcon" type="checkbox" label="Show Icon on Menu Bar (Need to restart the application)" checked={ this.state.showTrayIcon } onChange={ this.handleChangeShowTrayIcon } options.push(<Input ref="showTrayIcon" type="checkbox" label="Show Icon on Menu Bar (Need to restart the application)" checked={ this.state.showTrayIcon } onChange={ this.handleChangeShowTrayIcon }
/>); />);
} }
options.push(<Input ref="disablewebsecurity" type="checkbox" label="Allow insecure contents (This allows not only insecure images, but also insecure scripts)" checked={ this.state.disablewebsecurity }
onChange={ this.handleChangeDisableWebSecurity } />);
var options_row = (options.length > 0) ? ( var options_row = (options.length > 0) ? (
<Row> <Row>
<Col md={ 12 }> <Col md={ 12 }>

View File

@@ -24,6 +24,7 @@ var loadDefault = function(version) {
teams: [], teams: [],
hideMenuBar: false, hideMenuBar: false,
showTrayIcon: false, showTrayIcon: false,
disablewebsecurity: false,
version: 1 version: 1
}; };
} }