-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
[Bug]: mtree_spec
rule does not encode filenames with special characters
#794
Comments
mtree_spec
function does not encode filenames with special characters mtree_spec
rule does not encode filenames with special characters
Hmm I started a PR on this and am realizing that the use of The The In any case, that's a much bigger PR. I think I will have to move away from using this |
We already had to add So I think that path of fixing the mtree we write following the spec is viable |
If we did go that route - we already have release automation to build four other Go utilities and expose them as pre-built binary toolchains for users, so that's totally viable as well |
Hmm I looked at it and this implementation only works for ascii, would not work for
I don't think this is possible in starlark... you can't iterate the individual bytes of a unicode string. |
Interesting, I didn't know git uses something like this too?
Prepping to commit these files:
|
@alexeagle I pushed #795 if you want to continue working on it, or feel free to close the PR and start a new one, I don't need the commit attribution. |
hello. diff --git a/lib/private/tar.bzl b/lib/private/tar.bzl
index 0bc8a2e..db064c1 100644
--- a/lib/private/tar.bzl
+++ b/lib/private/tar.bzl
@@ -161,16 +161,17 @@ def _tar_impl(ctx):
return DefaultInfo(files = depset([out]), runfiles = ctx.runfiles([out]))
def _mtree_line(file, type, content = None, uid = "0", gid = "0", time = "1672560000", mode = "0755"):
spec = [
- file,
+ file.replace(" ", "\\040"),
"uid=" + uid,
"gid=" + gid,
"time=" + time,
"mode=" + mode,
"type=" + type,
]
if content:
+ content = content.replace(" ", "\\040")
spec.append("content=" + content)
return " ".join(spec)
# This function exactly same as the one from "@aspect_bazel_lib//lib:paths.bzl" via: http_archive(
name = "aspect_bazel_lib",
sha256 = "a8a92645e7298bbf538aa880131c6adb4cf6239bbd27230f077a00414d58e4ce",
strip_prefix = "bazel-lib-2.7.2",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.7.2/bazel-lib-v2.7.2.tar.gz",
patches = [
# workaround for https://github.com/aspect-build/bazel-lib/issues/794
"//:[email protected]_spec.patch",
],
patch_args = ["-p1"],
) |
Bazel's Starlark does not provide access to a string's bytes, only its codepoints, so we are unable to do this escaping in Starlark. So a second pass is needed, at least until the spec and implementation work to get a [`bytes` type](bazelbuild/starlark#112) lands. Fixes bazel-contrib#794
What happened?
The
mtree_spec
rule generates an invalid mtree entries for filenames with special characters. For example:Causes:
Filenames should be encoded according to
vis
(seeman vis
)In this case it should be encoded as:
References:
Version
How to reproduce
No response
Any other information?
No response
The text was updated successfully, but these errors were encountered: