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

escape filename when assemble URL (#22850) #22871

Merged
merged 1 commit into from
Feb 12, 2023

Commits on Feb 12, 2023

  1. escape filename when assemble URL (go-gitea#22850)

    Fixes: go-gitea#22843 
    
    ### Cause:
    
    https://github.com/go-gitea/gitea/blob/affdd40296960a08a4223330ccbd1fb88c96ea1a/services/repository/files/content.go#L161
    
    Previously, we did not escape the **"%"** that might be in "treePath"
    when call "url.parse()".
    
    
    ![image](https://user-images.githubusercontent.com/33891828/218066318-5a909e50-2a17-46e6-b32f-684b2aa4b91f.png)
    
    This function will check whether "%" is the beginning of an escape
    character. Obviously, the "%" in the example (hello%mother.txt) is not
    that. So, the function will return a error.
    
    ### Solution:
    We can escape "treePath" by call "url.PathEscape()" function firstly.
    
    ### Screenshot:
    
    ![image](https://user-images.githubusercontent.com/33891828/218069781-1a030f8b-18d0-4804-b0f8-73997849ef43.png)
    
    ---------
    
    Signed-off-by: Andrew Thornton <art27@cantab.net>
    Co-authored-by: Andrew Thornton <art27@cantab.net>
    2 people authored and yardenshoham committed Feb 12, 2023
    Configuration menu
    Copy the full SHA
    bc86ee5 View commit details
    Browse the repository at this point in the history