-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 bug to go to 404 when creating pull request #29059
Conversation
OK, I remember now, that's the reason why I left a "FIXME" there but didn't change it to JSONError. |
Toast always escapes HTML in the message. If you still want to render HTML in it, a option like |
-> Refactor locale&string&template related code #29165 |
Clarify when "string" should be used (and be escaped), and when "template.HTML" should be used (no need to escape) And help PRs like #29059 , to render the error messages correctly.
Clarify when "string" should be used (and be escaped), and when "template.HTML" should be used (no need to escape) And help PRs like go-gitea#29059 , to render the error messages correctly.
After checked the discussion above and #29165, I remember the fix of #26129 is not enough, as it will remove the dirty data and redirect to 404 when git hook check failed, but user will not know what happened as no error info will be displayed. @CaiCandong did some fix of display the error info in #26258, but at that time we can not handle these escaped html codes. |
Clarify when "string" should be used (and be escaped), and when "template.HTML" should be used (no need to escape) And help PRs like go-gitea#29059 , to render the error messages correctly.
Clarify when "string" should be used (and be escaped), and when "template.HTML" should be used (no need to escape) And help PRs like go-gitea#29059 , to render the error messages correctly. (cherry picked from commit f3eb835) Conflicts: modules/web/middleware/binding.go routers/web/feed/convert.go tests/integration/branches_test.go tests/integration/repo_branch_test.go trivial context conflicts
I think the approvals are too quick, at least, the HTML problem hasn't been resolved here. I only added necessary support in #29165 , but this PR doesn't really make the toast use HTML content correctly. |
How to reproduce the HTML toast? We could make it render HTML if all content in the HTML is trusted, e.g. no user content. |
I moved it back to flash but not Toast. |
Ok, but flash also needs to ensure to correctly escape user content 😉. |
This reverts commit 9d120ba.
Should we do that, the output comes from the hooks scripts. Maybe administrators should guarantee that since he has got root permission of Gitea. |
ctx.Flash.Error(flashError) | ||
ctx.JSONRedirect(pullIssue.Link()) // FIXME: it's unfriendly, and will make the content lost | ||
ctx.Flash.Warning(flashError) | ||
ctx.JSONRedirect(ctx.Link) |
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.
Well, the code just went back to the old. So why need this PR then?
(Oh I see, fix the 404 .... use a ctx.Link now)
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.
But why not keep the "Error" and keep the comment?
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.
The UI very special, when using Error, the error prompt section will displayed on the left of the input box.
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.
So when developing Gitea, when there is a unclear problem, should it always be hacky patched, but not really resolve it clearly?
At least, from the framework's view, Flash.Error and Flash.Warning should behave similarly?
I have made some changes, but no idea why I can't push changes to the PR which has enabled "Maintainers are allowed to edit this pull request". Maybe I need to open a new PR. |
Please, then I will close this one. |
-> Fix incorrect redirection when create PR fails #29537 And I figured out that the old layout for "alert" is wrong, that's why you see "strange special UI". |
The answer is: the "message" is fully escaped and sanitized, correctly. See the related code. |
replace by #29537 |
The
issuePull
doesn't exist if creating pull request failed. So redirect to issuePull.Link is wrong.