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

Implement basic file uploads to wiki #6024

Closed
wants to merge 1 commit into from
Closed

Implement basic file uploads to wiki #6024

wants to merge 1 commit into from

Conversation

gabrielsimoes
Copy link
Contributor

@gabrielsimoes gabrielsimoes commented Feb 9, 2019

Closes #574

Signed-off-by: Gabriel Silva Simões [email protected]

This allows uploading files to the root of the wiki repo. It doesn't add any deleting feature, but I suppose if a user needs that feature, he/she should be cloning the wiki repo and managing the files there (which is the only way to do that on Github),

Closes #574

Signed-off-by: Gabriel Silva Simões <[email protected]>
@codecov-io
Copy link

Codecov Report

Merging #6024 into master will decrease coverage by 0.06%.
The diff coverage is 2.29%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6024      +/-   ##
==========================================
- Coverage   38.73%   38.66%   -0.07%     
==========================================
  Files         332      332              
  Lines       48992    49079      +87     
==========================================
+ Hits        18976    18977       +1     
- Misses      27269    27354      +85     
- Partials     2747     2748       +1
Impacted Files Coverage Δ
models/wiki.go 45.68% <0%> (-16.82%) ⬇️
modules/auth/repo_form.go 38.23% <0%> (-0.77%) ⬇️
routers/repo/wiki.go 46.35% <0%> (-4.45%) ⬇️
routers/routes/routes.go 83.14% <100%> (+0.04%) ⬆️
modules/process/manager.go 76.81% <0%> (-4.35%) ⬇️
models/repo_list.go 64.55% <0%> (+1.26%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 681345d...c37ec89. Read the comment docs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 9, 2019
@lafriks lafriks added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Feb 9, 2019
// Copy uploaded files into repository.
for _, upload := range uploads {
tmpPath := upload.LocalPath()
targetPath := path.Join(localPath, upload.Name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will allow you to write to arbitrary places in the filesystem. Admittedly you can't overwrite anything with your current code but you can certainly inject into hooks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this could be solved by using the hash of the file path instead of the actual path, in a way similar to what is currently done with avatars (although for avatars it's a hash of the file contents, which I don't think is the best way here).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guillep2k I think if we look for forbidden pathern this shouldnt be a problem. If we hash files on the wiki wont have a human redable name anymore

allow normal chars a-Z numbers and '-' '_' '.' and add a check for /../ patterns

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@6543 but then the users will need to think about how they need to name their files. We should allow them to use any name, as long as it renders a serviceable path from Macaron (i.e. no slashes, no empty string).

}

if err := ctx.Repo.Repository.UploadWikiFiles(ctx.User, strings.TrimSpace(form.Message), form.Files); err != nil {
ctx.ServerError("DeleteWikiPage", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why DeleteWikiPage

Copy link
Contributor

@zeripath zeripath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your current code allows for arbitrary insertion of data, and you can't update or delete uploaded data.

@techknowlogick techknowlogick added this to the 1.9.0 milestone Feb 9, 2019
@lafriks
Copy link
Member

lafriks commented Feb 10, 2019

@zeripath updating and deletion is out of scope for this PR

@zeripath
Copy link
Contributor

The thing is just allowing uploads on the wiki is easy - as this PR shows - it's coming up with the rest of the UI that makes this difficult.

I don't think we should allow uploads without a way to manage these or at least a proposed UI. Saying you can simply git checkout and push from there there isn't really going to answer the problem - you could do that before.

@lunny
Copy link
Member

lunny commented Mar 20, 2019

After uploaded files, it should be listed some place to easily reference them?

@stale
Copy link

stale bot commented May 19, 2019

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 months. Thank you for your contributions.

@stale stale bot added the issue/stale label May 19, 2019
@lunny lunny added the issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented label May 19, 2019
@stale stale bot removed the issue/stale label May 19, 2019
@techknowlogick techknowlogick modified the milestones: 1.9.0, 1.10.0 Jun 4, 2019
@@ -22,7 +22,7 @@ import (
)

var (
reservedWikiNames = []string{"_pages", "_new", "_edit", "raw"}
reservedWikiNames = []string{"_pages", "_new", "_edit", "_upload", "raw"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a migration check or something if we add a new reserved name.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should reverse all word begin with _. :)

@lunny
Copy link
Member

lunny commented Sep 15, 2019

Please resolve the conflicts.

@lunny lunny modified the milestones: 1.10.0, 1.11.0 Sep 27, 2019
@lunny lunny modified the milestones: 1.11.0, 1.12.0 Nov 16, 2019
@6543
Copy link
Member

6543 commented Dec 25, 2019

@gabrielsimoes can you resolve the confilct?

@lunny lunny modified the milestones: 1.12.0, 1.x.x May 2, 2020
@ivptr ivptr mentioned this pull request Dec 22, 2022
@lunny lunny removed this from the 1.x.x milestone Jan 18, 2023
@wxiaoguang
Copy link
Contributor

It seems that this PR has been stale for long time, so ...... activate it or close it?

@wxiaoguang wxiaoguang added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Apr 25, 2023
@wxiaoguang
Copy link
Contributor

It has been stale for a long time and I can't think of a way to handling it other than closing it. Feel free to reopen if there's any new progress and I could also help.

@wxiaoguang wxiaoguang closed this May 1, 2023
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Aug 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uploads on the wiki
10 participants