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

chrome-clipboard fails on images with '_xsrf' argument missing from POST #918

Closed
sdsawtelle opened this issue Mar 16, 2017 · 7 comments
Closed

Comments

@sdsawtelle
Copy link
Contributor

sdsawtelle commented Mar 16, 2017

I am on Windows 10 with Chrome 56.0.2924.87 and Javascript V8 5.6.326.50 and using Jupyter Notebook 4.4.1

I did the following:

conda install -c conda-forge jupyter_contrib_nbextensions
jupyter contrib nbextension install --user

Then I started my notebook server, used the nbextensions tab to enable chrome-clipboard and restarted my notebook server.

I verified that copy/paste works for notebook cells but does not seem to be working for images.

Trace is:

[W 17:03:42.389 NotebookApp] 403 PUT /api/contents/upwork-data-analyst/XHFUUT31TAAV4CVIN0G350VMBCUDMM4O.png (::1): '_xsrf' argument missing from POST
[W 17:03:42.391 NotebookApp] 403 PUT /api/contents/upwork-data-analyst/XHFUUT31TAAV4CVIN0G350VMBCUDMM4O.png (::1) 3.50ms referer=http://localhost:8888/notebooks/upwork-data-analyst/testing-psycopg2-and-sqlalchemy.ipynb

I also tried to enable the extension with jupyter nbextension enable chrome-clipboard/main and restarting my notebook server, but made no difference.

@sdsawtelle sdsawtelle changed the title chrome-clipboard not working with images chrome-clipboard fails with '_xsrf' argument missing from POST Mar 17, 2017
@sdsawtelle sdsawtelle changed the title chrome-clipboard fails with '_xsrf' argument missing from POST chrome-clipboard fails on images with '_xsrf' argument missing from POST Mar 18, 2017
@juhasch
Copy link
Member

juhasch commented Mar 19, 2017

This sounds similar to #830. Can you check if your version of nbextensions contain the fix from #831 ?

You can check this by looking at http://localhost:8888/nbextensions/dragdrop/main.js and verify it contains the new utils.promising_ajax call in line 54.

@sdsawtelle
Copy link
Contributor Author

Thanks @juhasch - I appreciate your work on these awesome extensions.

Just to clarify, dragdrop works fine and does not throw errors, but copy paste with chrome-clipboard is what is giving the error when trying to paste images.

I can verify that line 54 of dragdrop/main.js is calling:
utils.promising_ajax(IPython.contents.api_url(path), settings);

However, chrome-clipboard/main.js has a somewhat different send_to_server() definition and just calls:
$.ajax(url, settings);

@juhasch
Copy link
Member

juhasch commented Mar 19, 2017

Thanks for the feedback. I thought of the other extension, as the reason for the error is most likely exactly the same: The API call needs to be updated to work with the new security measures in the notebook.

Do you want to try to fix it yourself ? Otherwise I will try to come up with a fix next week.

@sdsawtelle
Copy link
Contributor Author

OK thanks, it's working now with just minor tweaks. Should I submit a pull request? I've not contributed to an open-source project before.

@jcb91
Copy link
Member

jcb91 commented Mar 20, 2017

Should I submit a pull request?

Sure, that'd be great 😄 I found a handy guide if you haven't come across the workflow before: https://yangsu.github.io/pull-request-tutorial/

I've not contributed to an open-source project before.

Well, now's your chance 😉

@sdsawtelle
Copy link
Contributor Author

Sounds good, thanks for the link @jcb91!

sdsawtelle added a commit to sdsawtelle/jupyter_contrib_nbextensions that referenced this issue Mar 22, 2017
Reference Issue ipython-contrib#918. Update the API call for the PUT request to work with the new security measures in the notebook. Now uses promising_ajax() in base/js/utils/.
jcb91 added a commit that referenced this issue Mar 22, 2017
Update API for chrome-clipboard PUT request per #918.
@jcb91
Copy link
Member

jcb91 commented Mar 22, 2017

should be fixed by #921, please repoen if not!

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

3 participants