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

[MI-54922] Replaced the "text/template" package with "html/template" #988

Merged
merged 4 commits into from
Nov 20, 2023

Conversation

raghavaggarwal2308
Copy link
Contributor

Summary

Replaced the "text/template" package with "html/template"

@mickmister mickmister added 2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester labels Oct 18, 2023
Copy link
Member

@jupenur jupenur left a comment

Choose a reason for hiding this comment

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

I don't think this will work since there's a mixture of HTML and non-HTML templates that we use. Only the ones that are actually HTML should use html/template.

@raghavaggarwal2308
Copy link
Contributor Author

@jupenur I have tested it for "application/json" and "markdown" templates, and everything seems to work fine. Also, in the documentation of html/template, it's mentioned that this package wraps "text/template". Please let me know your opinions on this.

This package wraps [text/template](https://pkg.go.dev/text/template) so you can share its template API to parse and execute HTML templates safely.

@mickmister
Copy link
Contributor

@raghavaggarwal2308 In general, we should only use the html/template library when we are specifically generating HTML for the response. It has different behavior than text/template in that it sanitizes the input in ways that we may otherwise want to preserve when the output is not intended to be HTML

@raghavaggarwal2308
Copy link
Contributor Author

@mickmister @jupenur Updated logic to use 'html/template' for HTML templates only.

server/command_test.go Show resolved Hide resolved
server/http.go Outdated Show resolved Hide resolved
Copy link
Contributor

@mickmister mickmister left a comment

Choose a reason for hiding this comment

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

LGTM

server/http.go Outdated Show resolved Hide resolved
Co-authored-by: Abhishek Verma <72438220+avas27JTG@users.noreply.github.com>
@codecov-commenter
Copy link

codecov-commenter commented Oct 30, 2023

Codecov Report

Attention: 35 lines in your changes are missing coverage. Please review.

Comparison is base (d1e233a) 29.65% compared to head (dddb81d) 29.69%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #988      +/-   ##
==========================================
+ Coverage   29.65%   29.69%   +0.04%     
==========================================
  Files          52       52              
  Lines        7794     7812      +18     
==========================================
+ Hits         2311     2320       +9     
- Misses       5287     5295       +8     
- Partials      196      197       +1     
Files Coverage Δ
server/command.go 15.32% <100.00%> (ø)
server/user_cloud_oauth.go 0.00% <0.00%> (ø)
server/user_cloud.go 0.00% <0.00%> (ø)
server/plugin.go 11.43% <0.00%> (-0.05%) ⬇️
server/user_server.go 7.33% <0.00%> (ø)
server/http.go 69.62% <31.57%> (-0.43%) ⬇️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mickmister mickmister removed the 2: Dev Review Requires review by a core committer label Oct 30, 2023
Copy link

@AayushChaudhary0001 AayushChaudhary0001 left a comment

Choose a reason for hiding this comment

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

Tested and Approved
Working fine for both cloud and server, LGTM

@mickmister mickmister added 4: Reviews Complete All reviewers have approved the pull request and removed 3: QA Review Requires review by a QA tester labels Nov 20, 2023
@mickmister mickmister merged commit 675961b into mattermost:master Nov 20, 2023
9 checks passed
@avas27JTG avas27JTG mentioned this pull request Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants