Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
fix security issue (#68)
Browse files Browse the repository at this point in the history
fixes #67
  • Loading branch information
sindresorhus committed May 25, 2016
1 parent 85dbe40 commit 00113d1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
17 changes: 3 additions & 14 deletions browser.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';
/* globals Mousetrap scrollToTweet */
const path = require('path');
const electron = require('electron');
const Mousetrap = require('./vendor/mousetrap.js');
require('./vendor/mousetrap-global-bind.js');
const scrollToTweet = require('./vendor/scroll-to-tweet.js');
const ipc = electron.ipcRenderer;
const remote = electron.remote;
const storage = remote.require('./storage');
const $ = document.querySelector.bind(document);
// const $$ = document.querySelectorAll.bind(document);

function changeTab(next) {
const pages = [
Expand Down Expand Up @@ -218,17 +218,6 @@ function zoomInit() {
}

document.addEventListener('DOMContentLoaded', () => {
// load vendor scripts
[
path.resolve('vendor/mousetrap.js'),
path.resolve('vendor/mousetrap-global-bind.js'),
path.resolve('vendor/scroll-to-tweet.js')
].forEach(src => {
const script = document.createElement('script');
script.textContent = `require('${src}')`;
document.head.appendChild(script);
});

zoomInit();

// enable OS specific styles
Expand Down
5 changes: 1 addition & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ function createMainWindow() {
backgroundColor: isDarkMode ? '#192633' : '#fff',
webPreferences: {
preload: path.join(__dirname, 'browser.js'),
// removed until preloads accepts more than a single file
// ref: https://github.com/electron/electron/issues/5400
// nodeIntegration: false,
webSecurity: false,
nodeIntegration: false,
plugins: true
}
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"devDependencies": {
"electron-packager": "^7.0.0",
"electron-prebuilt": "^1.1.1",
"electron-prebuilt": "^1.1.2",
"xo": "*"
},
"xo": {
Expand Down
4 changes: 4 additions & 0 deletions vendor/scroll-to-tweet.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ Updates should happen there first.

window.scrollTo(0, scrollTarget);
};

if (typeof module !== 'undefined' && module.exports) {
module.exports = window.scrollToTweet;
}
})();

0 comments on commit 00113d1

Please sign in to comment.