Skip to content

Commit 5b83deb

Browse files
committed
Load js-url lib using legacy-loader
Doesn't use eval, plus no window object access
1 parent 996cb37 commit 5b83deb

4 files changed

Lines changed: 17 additions & 7 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"js-yaml": "^3.7.0",
5757
"jsdom-nogyp": "^0.8.3",
5858
"keymaster": "^1.6.2",
59+
"legacy-loader": "0.0.2",
5960
"list.js": "^1.5.0",
6061
"lodash": "^4.17.4",
6162
"lz-string": "1.4.4",

public/js/history.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ import {
1212
urlpath
1313
} from './lib/config'
1414

15+
var jsUrl = require('js-url')
16+
1517
window.migrateHistoryFromTempCallback = null
1618

1719
migrateHistoryFromTemp()
1820

1921
function migrateHistoryFromTemp () {
20-
if (window.url('#tempid')) {
22+
if (jsUrl('#tempid')) {
2123
$.get(`${serverurl}/temp`, {
22-
tempid: window.url('#tempid')
24+
tempid: jsUrl('#tempid')
2325
})
2426
.done(data => {
2527
if (data && data.temp) {

public/js/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
modeType, Idle, serverurl, key, gapi, Dropbox, FilePicker
44
ot, MediaUploader, hex2rgb, num_loaded, Visibility */
55

6+
67
require('../vendor/showup/showup')
78

89
require('../css/index.css')
@@ -21,6 +22,8 @@ import _ from 'lodash'
2122

2223
import List from 'list.js'
2324

25+
var jsUrl = require('js-url')
26+
2427
import {
2528
checkLoginStateChanged,
2629
setloginStateChangeEvent
@@ -1474,12 +1477,12 @@ $('#gistImportModalConfirm').click(function () {
14741477
if (!isValidURL(gisturl)) {
14751478
showMessageModal('<i class="fa fa-github"></i> Import from Gist', 'Not a valid URL :(', '', '', false)
14761479
} else {
1477-
var hostname = window.url('hostname', gisturl)
1480+
var hostname = jsUrl('hostname', gisturl)
14781481
if (hostname !== 'gist.github.com') {
14791482
showMessageModal('<i class="fa fa-github"></i> Import from Gist', 'Not a valid Gist URL :(', '', '', false)
14801483
} else {
14811484
ui.spinner.show()
1482-
$.get('https://api.github.com/gists/' + window.url('-1', gisturl))
1485+
$.get('https://api.github.com/gists/' + jsUrl('-1', gisturl))
14831486
.done(function (data) {
14841487
if (data.files) {
14851488
var contents = ''

webpackBaseConfig.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ module.exports = {
190190
index: [
191191
'babel-polyfill',
192192
'script!jquery-ui-resizable',
193-
'script!js-url',
193+
'js-url',
194194
'expose?filterXSS!xss',
195195
'script!Idle.Js',
196196
'expose?LZString!lz-string',
@@ -241,7 +241,7 @@ module.exports = {
241241
'expose?jsyaml!js-yaml',
242242
'script!mermaid',
243243
'expose?moment!moment',
244-
'script!js-url',
244+
'js-url',
245245
'script!handlebars',
246246
'expose?hljs!highlight.js',
247247
'expose?emojify!emojify.js',
@@ -374,7 +374,8 @@ module.exports = {
374374
'bootstrap-tooltip': path.join(__dirname, 'public/vendor/bootstrap/tooltip.min.js'),
375375
'headjs': path.join(__dirname, 'node_modules/reveal.js/lib/js/head.min.js'),
376376
'reveal-markdown': path.join(__dirname, 'public/js/reveal-markdown.js'),
377-
abcjs: path.join(__dirname, 'public/vendor/abcjs_basic_3.1.1-min.js')
377+
abcjs: path.join(__dirname, 'public/vendor/abcjs_basic_3.1.1-min.js'),
378+
'js-url': path.join(__dirname, 'node_modules/js-url/url.js')
378379
}
379380
},
380381

@@ -429,6 +430,9 @@ module.exports = {
429430
}, {
430431
test: /\.gif(\?v=\d+\.\d+\.\d+)?$/,
431432
loader: 'url?limit=10000&mimetype=image/gif'
433+
}, {
434+
test: /\/node_modules\/js-url\/url.js/,
435+
loader: 'legacy'
432436
}]
433437
},
434438
node: {

0 commit comments

Comments
 (0)