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: dockerfile2llb: handle escaping of backslashes correctly #5269

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Sep 9, 2024

  1. fix: dockerfile2llb: handle escaping of backslashes correctly

    `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]>
    profnandaa committed Sep 9, 2024
    Configuration menu
    Copy the full SHA
    538bdcf View commit details
    Browse the repository at this point in the history