-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Configure ember-auto-import so we can use a stricter CSP * Create a fake filesystem using JSON to avoid inline scripts in index We used to have inline scripts in index.html in order to support embers filepath fingerprinting and our configurable rootURL. Instead of using inline scripts we use application/json plus a JSON blob to create a fake filesystem JSON blob/hash/map to hold all of the rootURL'ed fingerprinted file paths which we can then retrive later in non-inline scripts. We move our inlined polyfills script into the init.js external script, and we move the CodeMirror syntax highlighting configuration inline script into the main app itself - into the already existing CodeMirror initializer (this has been moved so we can lookup a service located document using ember's DI container) * Set a strict-ish CSP policy during development
- Loading branch information
Showing
7 changed files
with
71 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:improvement | ||
ui: support stricter content security policies | ||
``` |
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
ui/packages/consul-ui/app/instance-initializers/ivy-codemirror.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* globals CodeMirror */ | ||
export function initialize(application) { | ||
const appName = application.application.name; | ||
const doc = application.lookup('service:-document'); | ||
// pick codemirror syntax highlighting paths out of index.html | ||
const fs = JSON.parse(doc.querySelector(`[data-${appName}-fs]`).textContent); | ||
// configure syntax highlighting for CodeMirror | ||
CodeMirror.modeURL = { | ||
replace: function(n, mode) { | ||
switch (mode) { | ||
case 'javascript': | ||
return fs['codemirror/mode/javascript/javascript.js']; | ||
case 'ruby': | ||
return fs['codemirror/mode/ruby/ruby.js']; | ||
case 'yaml': | ||
return fs['codemirror/mode/yaml/yaml.js']; | ||
} | ||
}, | ||
}; | ||
|
||
const IvyCodeMirrorComponent = application.resolveRegistration('component:ivy-codemirror'); | ||
// Make sure ivy-codemirror respects/maintains a `name=""` attribute | ||
IvyCodeMirrorComponent.reopen({ | ||
attributeBindings: ['name'], | ||
}); | ||
} | ||
|
||
export default { | ||
initialize, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters