mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 11:16:31 -05:00
Merge pull request #485 from codimd/fix/dropbox
This commit is contained in:
commit
f862b7a1e4
3 changed files with 23 additions and 3 deletions
|
@ -32,6 +32,10 @@ var googleAnalyticsDirectives = {
|
||||||
scriptSrc: ['https://www.google-analytics.com']
|
scriptSrc: ['https://www.google-analytics.com']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var dropboxDirectives = {
|
||||||
|
scriptSrc: ['https://www.dropbox.com', '\'unsafe-inline\'']
|
||||||
|
}
|
||||||
|
|
||||||
CspStrategy.computeDirectives = function () {
|
CspStrategy.computeDirectives = function () {
|
||||||
var directives = {}
|
var directives = {}
|
||||||
mergeDirectives(directives, config.csp.directives)
|
mergeDirectives(directives, config.csp.directives)
|
||||||
|
@ -39,6 +43,7 @@ CspStrategy.computeDirectives = function () {
|
||||||
mergeDirectivesIf(config.useCDN, directives, cdnDirectives)
|
mergeDirectivesIf(config.useCDN, directives, cdnDirectives)
|
||||||
mergeDirectivesIf(config.csp.addDisqus, directives, disqusDirectives)
|
mergeDirectivesIf(config.csp.addDisqus, directives, disqusDirectives)
|
||||||
mergeDirectivesIf(config.csp.addGoogleAnalytics, directives, googleAnalyticsDirectives)
|
mergeDirectivesIf(config.csp.addGoogleAnalytics, directives, googleAnalyticsDirectives)
|
||||||
|
mergeDirectivesIf(config.dropbox.appKey, directives, dropboxDirectives)
|
||||||
if (!areAllInlineScriptsAllowed(directives)) {
|
if (!areAllInlineScriptsAllowed(directives)) {
|
||||||
addInlineScriptExceptions(directives)
|
addInlineScriptExceptions(directives)
|
||||||
}
|
}
|
||||||
|
|
|
@ -944,7 +944,8 @@ ui.toolbar.download.rawhtml.click(function (e) {
|
||||||
// pdf
|
// pdf
|
||||||
ui.toolbar.download.pdf.attr('download', '').attr('href', noteurl + '/pdf')
|
ui.toolbar.download.pdf.attr('download', '').attr('href', noteurl + '/pdf')
|
||||||
// export to dropbox
|
// export to dropbox
|
||||||
ui.toolbar.export.dropbox.click(function () {
|
ui.toolbar.export.dropbox.click(function (event) {
|
||||||
|
event.preventDefault()
|
||||||
var filename = renderFilename(ui.area.markdown) + '.md'
|
var filename = renderFilename(ui.area.markdown) + '.md'
|
||||||
var options = {
|
var options = {
|
||||||
files: [
|
files: [
|
||||||
|
@ -996,7 +997,8 @@ ui.toolbar.export.snippet.click(function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
// import from dropbox
|
// import from dropbox
|
||||||
ui.toolbar.import.dropbox.click(function () {
|
ui.toolbar.import.dropbox.click(function (event) {
|
||||||
|
event.preventDefault()
|
||||||
var options = {
|
var options = {
|
||||||
success: function (files) {
|
success: function (files) {
|
||||||
ui.spinner.show()
|
ui.spinner.show()
|
||||||
|
|
15
test/csp.js
15
test/csp.js
|
@ -27,7 +27,10 @@ describe('Content security policies', function () {
|
||||||
upgradeInsecureRequests: 'auto',
|
upgradeInsecureRequests: 'auto',
|
||||||
reportURI: undefined
|
reportURI: undefined
|
||||||
},
|
},
|
||||||
useCDN: true
|
useCDN: true,
|
||||||
|
dropbox: {
|
||||||
|
appKey: undefined
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -78,6 +81,16 @@ describe('Content security policies', function () {
|
||||||
assert(!csp.computeDirectives().fontSrc.includes('https://*.disquscdn.com'))
|
assert(!csp.computeDirectives().fontSrc.includes('https://*.disquscdn.com'))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Include dropbox if configured', function () {
|
||||||
|
let testconfig = defaultConfig
|
||||||
|
testconfig.dropbox.appKey = 'hedgedoc'
|
||||||
|
mock('../lib/config', testconfig)
|
||||||
|
csp = mock.reRequire('../lib/csp')
|
||||||
|
|
||||||
|
assert(csp.computeDirectives().scriptSrc.includes('https://www.dropbox.com'))
|
||||||
|
assert(csp.computeDirectives().scriptSrc.includes('\'unsafe-inline\''))
|
||||||
|
})
|
||||||
|
|
||||||
it('Set ReportURI', function () {
|
it('Set ReportURI', function () {
|
||||||
let testconfig = defaultConfig
|
let testconfig = defaultConfig
|
||||||
testconfig.csp.reportURI = 'https://example.com/reportURI'
|
testconfig.csp.reportURI = 'https://example.com/reportURI'
|
||||||
|
|
Loading…
Reference in a new issue