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

Supplying an encoded URI containing %20 in IOS causes a 'failed to open zip file' #285

Open
jaymes-bearden opened this issue Aug 30, 2023 · 0 comments

Comments

@jaymes-bearden
Copy link

Describe the bug
In Expo native, I have bundled a series of zip files with my application that are to be unpacked at runtime. These files are expo bundled, provided/loaded as require('my-local.zip') and locally resolved with expo-asset "resolveAsync" which supplies a file:// pointing to a "localUri". In Android, everything works great. In IOS; however, the zip file's localUri resolves to file:///var/mobile/Containers/Data/Application/.../Library/Application%20Support/.expo-internal/... (Note the %20). If you check for this file with expo-file-system FileSystem.getInfoAsync, this file correctly exists and is readable/writeable. If you attempt to unzip this local file uri, it will fail.

If you take this file URI and replace %20 with a space , the zip file correctly unzips as expected. Is it possible that the normalizeFilePath function can check/replace %20 with a space or perhaps do a URI decode on the supplied path? Or should we be doing this ourselves?

Expected behavior
A ZIP file from a URI containing URI encoding on IOS should unzip to the supplied destination.

Environment:

  • Device: iPad Air 4th gen
  • OS: iPadOS
  • OS Version: 16.6
  • Package Version: 6.0.9

Potential Solution
Adjust the normalizeFilePath as follows:

const normalizeFilePath = (path) => {
  const filePath = path.startsWith("file://") ? path.slice(7) : path;
  return filePath.replace('%20', ' '); // or decodeURI(filePath) ?
}

Additional context
If we should be providing normalized file uris, can the documentation be updated to indicate this?

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

No branches or pull requests

2 participants