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

Breaking summary for template refactoring #29395

Merged
merged 4 commits into from
Mar 3, 2024

Conversation

wxiaoguang
Copy link
Contributor

@wxiaoguang wxiaoguang commented Feb 25, 2024

This is a summary PR for the breakings of template refactoring, because there are many related PRs.


⚠️ BREAKING ⚠️

In Gitea 1.22, there are a lot of template related refactoring changes. The main purpose of these changes is to make Gitea's template system easier to use and more safe.

  • Safe is renamed to SafeHTML, and in most cases it shouldn't be used.
  • Escape is renamed to HTMLEscape, and in most cases it shouldn't be used. The template should escape most variables automatically.
  • Str2html is renamed to SanitizeHTML, only use it when necessary, it only "sanitizes" the input by pre-defined rules, but it doesn't "render" or "convert" the content.
  • Use HTMLFormat instead of printf when processing HTML related contents.

⚠️ To custom template users ⚠️

If you are using custom templates (including "mail" templates and "website" templates), after you upgrade to Gitea 1.22, you should extract the templates from Gitea and apply your changes with these new approaches. Keeping using the old custom templates would cause various problems (500 error, mail errors, double-escaping, etc)

@wxiaoguang wxiaoguang added the pr/breaking Merging this PR means builds will break. Needs a description what exactly breaks, and how to fix it! label Feb 25, 2024
@wxiaoguang wxiaoguang added this to the 1.22.0 milestone Feb 25, 2024
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 25, 2024
@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Feb 25, 2024
@wxiaoguang wxiaoguang marked this pull request as draft February 25, 2024 14:14
@delvh
Copy link
Member

delvh commented Feb 25, 2024

Why WIP?

@delvh
Copy link
Member

delvh commented Feb 25, 2024

And isn't this PR the opposite of breaking?

@wxiaoguang
Copy link
Contributor Author

wxiaoguang commented Feb 25, 2024

Why WIP?

Because it (the refactoring) hasn't finished yet .....

@pull-request-size pull-request-size bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 1, 2024
@wxiaoguang wxiaoguang marked this pull request as ready for review March 1, 2024 10:37
@wxiaoguang wxiaoguang changed the title WIP: Breaking summary for template refactoring Breaking summary for template refactoring Mar 1, 2024
@wxiaoguang
Copy link
Contributor Author

Why WIP?

Ready now.

modules/templates/mailer.go Outdated Show resolved Hide resolved
@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 Mar 2, 2024
@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 Mar 3, 2024
@wxiaoguang wxiaoguang enabled auto-merge (squash) March 3, 2024 04:33
@wxiaoguang wxiaoguang merged commit e71b692 into go-gitea:main Mar 3, 2024
26 checks passed
@wxiaoguang wxiaoguang deleted the breaking-template branch March 3, 2024 05:32
zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 3, 2024
* upstream/main:
  Breaking summary for template refactoring (go-gitea#29395)
  [skip ci] Updated translations via Crowdin
  Fix incorrect cookie path for AppSubURL (go-gitea#29534)
  gitea.service: Remove syslog.target (go-gitea#29550)
  Add option to set language in admin user view (go-gitea#28449)
  Fix elipsis button not working if the last commit loading is deferred (go-gitea#29544)
  Fix incorrect relative/absolute URL usages (go-gitea#29531)
  Add support for API blob upload of release attachments (go-gitea#29507)
  Fix queue worker incorrectly stopped when there are still more items in the queue (go-gitea#29532)
  remove util.OptionalBool and related functions (go-gitea#29513)
  Rename Action.GetDisplayName to GetActDisplayName (go-gitea#29540)
  Make PR form use toast to show error message (go-gitea#29545)
DennisRasey pushed a commit to DennisRasey/forgejo that referenced this pull request Mar 6, 2024
go-gitea/gitea#29395
(cherry picked from commit e71b69257c38178eed9ccd0b62a5ae47d67858d4)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/docs pr/breaking Merging this PR means builds will break. Needs a description what exactly breaks, and how to fix it! size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants