-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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: dockerfile2llb: handle escaping of backslashes correctly #5269
base: master
Are you sure you want to change the base?
Conversation
3c5b01f
to
32e6711
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this is correct. Don't we need something windows specific what would detect that if path is windows style then single backslashes should mean \\
instead of being escape characters?
Initially I'd thought of just windows-only variant but there such cases like cross-platform builds that could often have the This only has the effect on the Also you can see that the log lines currently preserve the backslashes correctly, but the stage name:
|
So what about this:
Is it incorrect or correct. Looks like |
Good catch. AFK, let me take a look at this later today. Thanks!
…On Fri, Aug 23, 2024, 13:11 Tõnis Tiigi ***@***.***> wrote:
So what about this:
» cat Dockerfile
from alpine
env foo=aa\bb
run env && stop
=> ERROR [2/2] RUN env && stop 0.2s
------
> [2/2] RUN env && stop:
0.114 SHLVL=1
0.114 foo=aabb
0.114 HOME=/root
Is it incorrect or correct. Looks like ProcessWord should assume that the
value is inside the string in this case?
—
Reply to this email directly, view it on GitHub
<#5269 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB7ZEMSZW3H4BQ44JJYO33ZS4DGRAVCNFSM6AAAAABM6SN4RSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBWG43DINRTGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Let me revisit this right after my vctn, 9/3. |
@tonistiigi -- I think the log lines are writing out the bytes as received from the RUN call. Linux already strips off the
Equivalent running in an
This is what is coming back the other way round from the lower layers. My fix was fixing only the stage name display, where backslashes are stripped off before they go down from the dockerfile to LLB... |
PS: The log lines (just below the stage name), are raw bytes: buildkit/util/progress/progressui/printer.go Line 150 in b60d621
Then here is where the stage name is printed, but coming from
buildkit/solver/llbsolver/vertex.go Lines 42 to 47 in b60d621
|
`shlex` in was treating single backslash "\\" in string as escape sequence, hence stripping them off. Modify `processCmdEnv` to double escape `\\`. This was in turn affecting the vertex `Name`, and mostly pronounced on Windows where backslashes are prevalent in path names. For example `C:\hello\world\path` was being rendered as `C:helloworldpath`, hence confusing users. Fixes moby#5250 Build progress before fix: ``` moby#5 [2/4] RUN echo C:helloworldpath moby#5 1.359 C:\hello\world\path moby#5 DONE 1.7s moby#6 [3/4] RUN echo C:\hello\escaped\path moby#6 1.734 C:\\hello\\escaped\\path moby#6 DONE 2.1s moby#7 [4/4] RUN echo "C:\hello\quoted\path" moby#7 1.765 "C:\hello\quoted\path" moby#7 DONE 2.1s ``` Build progress after fix: ``` moby#5 [2/4] RUN echo C:\hello\world\path moby#5 1.458 C:\hello\world\path moby#5 DONE 1.8s moby#6 [3/4] RUN echo C:\\hello\\escaped\\path moby#6 1.730 C:\\hello\\escaped\\path moby#6 DONE 2.1s moby#7 [4/4] RUN echo "C:\hello\quoted\path" moby#7 1.702 "C:\hello\quoted\path" moby#7 DONE 2.1s ``` You can also see that now paths in the step/vertex names now match those in the log lines right after the name. Signed-off-by: Anthony Nandaa <[email protected]>
32e6711
to
538bdcf
Compare
rebased with the latest |
Testing current (not this PR) in linux:
and btw:
Is the issue that |
That's true, and not only on Windows alone, but Linux too... |
@tonistiigi -- PTAL again. |
@profnandaa Has this PR changed since my last comment #5269 (comment) ? |
Relooking into this again. From your test cases, this is what had caught my eyes:
Let me see the best way we can address this. |
shlex
in was treating single backslash "\" in string as escape sequence, hence stripping them off. ModifyprocessCmdEnv
to double escape\\
.This was in turn affecting the vertex
Name
, and mostly pronounced on Windows where backslashes are prevalent in path names. For exampleC:\hello\world\path
was being rendered asC:helloworldpath
, hence confusing users.Fixes #5250
Build progress before fix:
Build progress after fix:
You can also see that now paths in the step/vertex names now match those in the log lines right after the name.