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

fix: XSS issues in page descriptions #307

Merged
merged 4 commits into from
Apr 18, 2024
Merged

fix: XSS issues in page descriptions #307

merged 4 commits into from
Apr 18, 2024

Conversation

Brookke
Copy link
Member

@Brookke Brookke commented Sep 19, 2021

uses bluemonday to sanitize html, since we are loading in that library I have also applied the same to the strip html.

This did break a test turning <p>1</p><p>2</p> into 12 rather than 1\n\n2 I think this is an acceptable trade off since paragraphs should probably be on a new line anyway.

Copy link
Member

@markspolakovs markspolakovs left a comment

Choose a reason for hiding this comment

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

Looks alright to me once you fix the build failure

This did break a test turning

1

2

into 12 rather than 1\n\n2 I think this is an acceptable trade off since paragraphs should probably be on a new line anyway.

I’d agree, though I’d be interested to see how prevalent this is in the wild (e.g. does MyRadio’s TinyMCE put in newlines or not)

@@ -110,14 +111,6 @@ func RenderTemplate(w http.ResponseWriter, context structs.PageContext, data int
"formatTime": func(fmt string, t time.Time) string {
return t.Format(fmt)
},
// TODO(CaptainHayashi): this is temporary
"stripHTML": func(s string) string {
Copy link
Member

Choose a reason for hiding this comment

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

I assume you’ve checked this isn’t used anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes I have broken something, will fix that now 🤦🏼‍♂️, I thought it was re-declaration

Copy link
Member Author

Choose a reason for hiding this comment

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

oh bugger this new one doesnt handle ' properly
Screenshot 2021-09-19 at 19 35 41

Copy link
Member Author

Choose a reason for hiding this comment

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

Will take another look at this tomorrow, unless someone beats me to it :)

Copy link
Member

Choose a reason for hiding this comment

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

I look forward to any and all instances of hacky hayashicode being removed :o)

@Brookke
Copy link
Member Author

Brookke commented Apr 25, 2022

Just remembered this never got merged, I will circle back on this soon and lets get it in :)

@Brookke
Copy link
Member Author

Brookke commented Jun 5, 2022

Looks alright to me once you fix the build failure

This did break a test turning 12 into 12 rather than 1\n\n2 I think this is an acceptable trade off since paragraphs should probably be on a new line anyway.

I’d agree, though I’d be interested to see how prevalent this is in the wild (e.g. does MyRadio’s TinyMCE put in newlines or not)

One option here is to run the html through a formatter first

@Brookke Brookke requested a review from markspolakovs April 13, 2024 19:22
@Brookke
Copy link
Member Author

Brookke commented Apr 13, 2024

No idea who is best to review this these days, but I have rebased and made a few changes to get this into a state where it can be shipped.

RE #307 (comment)

I have just removed the title tag, not sure its helpful to have the full show description in a little tooltip anyway

This did break a test turning

1

2

into 12 rather than 1\n\n2 I think this is an acceptable trade off since paragraphs should probably be on a new line anyway.

RE the above - I have had a cursory glance at the current shows on the schedule and they all look like they are formatted correctly.

The value of this seems higher than the cost imo, finally closing out the XSS issue.

@Brookke Brookke merged commit 4304de1 into development Apr 18, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants