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

[WIP] Contents: avoid double-URIdecoding paths #1216

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tomjakubowski
Copy link
Contributor

@tomjakubowski tomjakubowski commented Oct 18, 2023

Hello! We're working on a jupyterlite integration over at https://prospective.co. I'm thrilled to contribute a bug fix back to jupyterlite! 🎉

References

Addresses #1211

Code changes

The paths coming in to /api/contents need to be URI decoded, because jupyterlab's frontend URI encodes them.

The existing Contents API would sometimes double-decode the filenames. For example, Contents.createCheckpoint() would decode the path once, then call this.get() on the path, which would decode it again.

To prevent double-decoding, the URI decode is moved out of the Contents class and into the route definitions.

User-facing changes

Users can now add both files from URLs containing percent-encoded characters, and files from their filesystem with names like hello%20world.txt.

Backwards-incompatible changes

This has a side effect of changing the Contents class API to accept "regular" paths, and not URI-encoded ones. For example, Contents.get("hello%20world.txt") will now return a file named hello%20world.txt on the filesystem, instead of a file named hello world.txt.

@github-actions
Copy link
Contributor

lite-badge 👈 Try it on ReadTheDocs

@tomjakubowski
Copy link
Contributor Author

tomjakubowski commented Oct 18, 2023

My coworker and I started on a ui-test for this, a new test which ran through "Open from URL", which is where I first saw the problem in #1211

Now that the fix is ready, the bug seems larger in scope than just opening from URLs. For example, dragging a file named hello%20world.txt into Jupyterlite would cause the same behavior. Would it be acceptable to instead write a unit/regression test for this in the contents package?

@tomjakubowski
Copy link
Contributor Author

still some weirdness on this branch! so very much a wip, which I have now marked

example of some remaining weirdness:

  1. Create a folder on your filesystem with files called hello%20world.txt and hello world.txt. See foo.zip
  2. Drag and drop hello world.txt into Jupyterlite.
  3. Drag and drop hello%20world.txt into Jupyterlite. Instead of adding a new file, it overwrites hello world.txt and renames it to hello%20world.txt

@tomjakubowski tomjakubowski marked this pull request as draft October 18, 2023 00:48
@tomjakubowski tomjakubowski changed the title Contents: avoid double-URIdecoding paths [WIP] Contents: avoid double-URIdecoding paths Oct 18, 2023
@jtpio jtpio added the bug Something isn't working label Oct 18, 2023
@@ -22,7 +22,7 @@ test.use({
waitForApplication: firefoxWaitForApplication,
});

test.describe('Contents Tests', () => {
test.describe.only('Contents Tests', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also use the -g Playwright command line option to only run a subset of the test suite.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! nice tip

@jtpio jtpio added this to the 0.2.x milestone Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants