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

fix: mutate.Extract path manipulation on Windows #2015

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

helsaawy
Copy link

mutate.Extract replaces / with \ on Windows (even for non-Windows images) due to the use of filepath.Clean(), and other functions (e.g., filepath.Dir) that ultimately call filepath.Clean on the result.
This is typically not desired, since:

  • the flattened image would not be valid on Linux
  • Windows can handle / as a path separator, if the result is meant to be extracted on Windows
  • the conversion may be non-reversible in the edge case where the image contains a file name with \

Add an imageFS interface to abstract away path manipulation operations (e.g., Dir, Base, Clean, Join), with the default case being filepath.*, but allows using path.* if extracting a non-Windows image on Windows.

Note: extracting a Windows image on Linux is left as is, since neither path nor filepath will be able to appropriately handle the paths if the separator is \.

`mutate.Extract` replaces `/` with `\` on Windows (even for non-Windows
images) due to the use of `filepath.Clean()` and other functions
(e.g., `filepath.Dir`) that ultimately call `filepath.Clean` on the
result.
This is typically not desired, since:
 - the flattened image would not be valid on Linux
 - Windows can handle `/` as a path separator, if the result is meant to
   be extracted on Windows
 - the conversion may be non-reversible in the edge case where the image
   contains a file name with `\`

Add an `imageFS` interface to abstract away path manipulation operations
(e.g., `Dir`, `Base`, `Clean`, `Join`), with the default case being
`filepath.*`, but allows using `path.*` if extracting a non-Windows
image on Windows.

Note: extracting a Windows image on Linux is left as is, since neither
`path` nor `filepath` will be able to appropriately handle the paths
if the separator is `\`.

Signed-off-by: Hamza El-Saawy <[email protected]>
Copy link

google-cla bot commented Sep 20, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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

Successfully merging this pull request may close these issues.

1 participant