Skip to content

Conversation

@locks
Copy link
Contributor

@locks locks commented Oct 26, 2019

No description provided.

@rust-highfive
Copy link

r? @sgrif

(rust_highfive has picked a reviewer for you, use r? to override)

@smarnach
Copy link
Contributor

What is the goal of this change? There is another occurrence of triple braces here; should that be replaced as well?

@locks
Copy link
Contributor Author

locks commented Oct 26, 2019

I have replaced the other occurrence :) The idea is that we should move away from triple mustaches. Since we still need to interpolate some HTML–which we kinda control anyway–the general advice is to use the htmlSafe utility instead.

@locks
Copy link
Contributor Author

locks commented Oct 26, 2019

I believe this is a lint starting with some version of ember.js, hence my change.

@locks locks force-pushed the triple-stache branch 3 times, most recently from 3e828a6 to 8dbc20c Compare October 26, 2019 16:21
Copy link
Contributor

@smarnach smarnach left a comment

Choose a reason for hiding this comment

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

Sorry for posting so many comments on such a simple PR. I'm not really a frontend person, so I need a bit of help to understand what's going on here – I'd like to understand the change before approving it. :)

<div class='stats'>
{{{ if user.email user.email "&nbsp;" }}}
{{#if user.email}}
{{html-safe user.email}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the user email really need html-safe? I believe the triple braces were only there to prevent &nbsp; from being escaped, and if you expand it the way you did we don't need it anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, good point. I tried to keep the exact same behaviour as I wasn't sure, but if we don't need it here then even better!

Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking about it, marking the email address as "safe" even appears to be actively harmful, and we don't do so in other places we show email addresses. This currently doesn't actually introduce an XSS vulnerability since the only email address we show is the address of the current user, so people could only attack themselves, but I'd prefer if you remove html-safe here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

import { helper } from '@ember/component/helper';
import { htmlSafe as markAsSafe } from '@ember/template';

export function htmlSafe([content] /*, hash*/) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use array destructuring on all browsers we support? Or do we compile the JS files somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

config/targets.js tells ember-cli-babel which browsers we support so it knows which features to compile, and I think our listed browsers support array destructuring. I'd have to check UCAndroid.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, the JS files are compiled with Babel, that's all I need to know. I don't know our frontend infrastructure too well.

@locks
Copy link
Contributor Author

locks commented Oct 28, 2019

Sorry for posting so many comments on such a simple PR.

No worries, that's what reviews are for 😁 it also helps me make sure I'm aligned.

@smarnach
Copy link
Contributor

Thanks for the updates, looks good to me now!

@bors r+

@bors
Copy link
Contributor

bors commented Oct 28, 2019

📌 Commit 5e935ca has been approved by smarnach

bors added a commit that referenced this pull request Oct 28, 2019
replace triple mustache with html-safe helper
@bors
Copy link
Contributor

bors commented Oct 28, 2019

⌛ Testing commit 5e935ca with merge 43619db...

@bors
Copy link
Contributor

bors commented Oct 28, 2019

☀️ Test successful - checks-travis
Approved by: smarnach
Pushing 43619db to master...

@bors bors merged commit 5e935ca into master Oct 28, 2019
@carols10cents carols10cents deleted the triple-stache branch November 4, 2019 15:38
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.

6 participants