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

When visit /favicon.ico and the static file is not exist return 404 but not continue to handle the route #14211

Merged
merged 2 commits into from
Jan 1, 2021

Conversation

lunny
Copy link
Member

@lunny lunny commented Jan 1, 2021

This should fix #13771. When requesting a route /favicon.ico and there is no static file found, a 404 should be given immediately but not continue next middlewares or routes.

@nuno-silva could you confirm this fix your problem?

@lunny lunny added this to the 1.14.0 milestone Jan 1, 2021
@lunny lunny changed the title When visit /favicon.ico but the static file is not exist return 404 but not continue to handle the route When visit /favicon.ico and the static file is not exist return 404 but not continue to handle the route Jan 1, 2021
@codecov-io
Copy link

codecov-io commented Jan 1, 2021

Codecov Report

Merging #14211 (b6fd8a9) into master (8c086ba) will increase coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #14211   +/-   ##
=======================================
  Coverage   42.01%   42.01%           
=======================================
  Files         734      734           
  Lines       78773    78773           
=======================================
+ Hits        33093    33096    +3     
+ Misses      40244    40242    -2     
+ Partials     5436     5435    -1     
Impacted Files Coverage Δ
modules/public/public.go 54.79% <ø> (ø)
modules/indexer/stats/db.go 56.00% <0.00%> (-4.00%) ⬇️
modules/process/manager.go 72.50% <0.00%> (-2.50%) ⬇️
modules/git/repo_commit_nogogit.go 63.33% <0.00%> (-1.67%) ⬇️
models/repo_list.go 78.76% <0.00%> (+0.88%) ⬆️
modules/queue/unique_queue_disk_channel.go 55.38% <0.00%> (+1.53%) ⬆️
modules/git/utils.go 80.55% <0.00%> (+2.77%) ⬆️
modules/git/repo_base_nogogit.go 72.72% <0.00%> (+9.09%) ⬆️

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 8c086ba...b6fd8a9. Read the comment docs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 1, 2021
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jan 1, 2021
Copy link
Contributor

@nuno-silva nuno-silva left a comment

Choose a reason for hiding this comment

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

It does indeed fix the problem. Thank you!


Applied the patch to gitea 1.13.1 and set REQUIRE_SIGNIN_VIEW = true:

  • before patch:
# curl -sI 127.0.0.1:3000/favicon.ico | grep -E "HTTP|redirect|Location"
HTTP/1.1 302 Found
Location: /user/login
Set-Cookie: redirect_to=%2Ffavicon.ico; Path=/
  • after:
# curl -sI 127.0.0.1:3000/favicon.ico | grep -E "HTTP|redirect|Location"
HTTP/1.1 404 Not Found

Note, however, that the issue can still happen if the browser requests some other arbitrary file not listed in KnownPublicEntries (though that's unlikely; can't remember anything right now).

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jan 1, 2021
@techknowlogick techknowlogick merged commit d44f192 into go-gitea:master Jan 1, 2021
@techknowlogick
Copy link
Member

@lunny please send backport :)

@lunny lunny deleted the lunny/fix_favicon_redirect branch January 2, 2021 01:46
lunny added a commit to lunny/gitea that referenced this pull request Jan 2, 2021
…ut not continue to handle the route (go-gitea#14211)

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
@lunny lunny added the backport/done All backports for this PR have been created label Jan 2, 2021
lunny added a commit that referenced this pull request Jan 2, 2021
…ut not continue to handle the route (#14211) (#14213)

Co-authored-by: techknowlogick <techknowlogick@gitea.io>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
@go-gitea go-gitea locked and limited conversation to collaborators Feb 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redirect to favicon.ico after login
6 participants