Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading lda.json as a local file causes security issues #100

Open
ielbert-cbi opened this issue Mar 6, 2020 · 1 comment
Open

Loading lda.json as a local file causes security issues #100

ielbert-cbi opened this issue Mar 6, 2020 · 1 comment

Comments

@ielbert-cbi
Copy link

Generated visualization cannot be opened as a local file. It triggers an error, something like

XMLHttpRequest cannot load file. Origin null is not allowed by Access-Control-Allow-Origin

The current implementation works around this issue by starting a local webserver but generated artifact cannot be shared with other users, reopened when the local webserver shuts down, etc.

Lighter (but hackier) solution is to initialize data (validated by Adam Detrick) is to read data in as a Javascript code and use it directly in LDAvis without loading via d3.json.

Proposed changes:

  1. Changed lda.json to data.js: assign JSON to const data= .
    It will look like: const data = { "mdsDat": {...

  2. Modify index.html:

  • insert <script src="data.js"></script> in
  • change call LDAvis("#lda", json_file) to LDAvis("#lda", data)
  1. Modify ldavis.js
  • change the first line to: LDAvis = function (to_select, data) {
  • remove lines: d3.json(json_file, function(error, data) { and corresponding )};

This is it. Now generated artifacts can be opened locally in any browser, shared among users, etc

@derbirch
Copy link

Generated visualization cannot be opened as a local file. It triggers an error, something like

XMLHttpRequest cannot load file. Origin null is not allowed by Access-Control-Allow-Origin

The current implementation works around this issue by starting a local webserver but generated artifact cannot be shared with other users, reopened when the local webserver shuts down, etc.

Lighter (but hackier) solution is to initialize data (validated by Adam Detrick) is to read data in as a Javascript code and use it directly in LDAvis without loading via d3.json.

Proposed changes:

  1. Changed lda.json to data.js: assign JSON to const data= .
    It will look like: const data = { "mdsDat": {...
  2. Modify index.html:
  • insert <script src="data.js"></script> in
  • change call LDAvis("#lda", json_file) to LDAvis("#lda", data)
  1. Modify ldavis.js
  • change the first line to: LDAvis = function (to_select, data) {
  • remove lines: d3.json(json_file, function(error, data) { and corresponding )};

This is it. Now generated artifacts can be opened locally in any browser, shared among users, etc

It works! Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants