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

Improve HTML sanitization on messages #573

Open
steveyken opened this issue Sep 23, 2022 · 2 comments
Open

Improve HTML sanitization on messages #573

steveyken opened this issue Sep 23, 2022 · 2 comments
Assignees

Comments

@steveyken
Copy link
Member

Chat messages have HTML sanitization to prevent js injection attacks.

However, we want to be able to display some HTML tags such as links and twilio audio.

There is some link detection in

parsedBody: Ember.computed("body", function() {
let body = this.get("body");
body = body.replace(/(<br>)/gm, "\n");
body = body.replace(/(<)/g, "&lt;");
let hrefExpressionMatch = body.match(
/\&lt;a href=(.*?)\>(.*?)\&lt;\/a\s*?\>/
);
if (hrefExpressionMatch) {
body = this.sanitizingAnchorLinks(body, hrefExpressionMatch);
}
return body;
}),
sanitizingAnchorLinks(body, hrefExpressionMatch) {
let originalLink = hrefExpressionMatch[0];
let anchorLink = hrefExpressionMatch[1];
let text = hrefExpressionMatch[2];
if (
anchorLink.includes("/plan_delivery") ||
anchorLink.includes(
"crossroads-foundation.formstack.com/forms/goods_donor_survey?field"
)
) {
body = body.replace(originalLink, `<a href=${anchorLink}>${text}</a>`);
}
return body;
},

but this is rudimentary and doesn't handle cases where a user has left a voicemail.

Example:

image

@steveyken
Copy link
Member Author

@patrixr made a good start on this on Saturday

@steveyken
Copy link
Member Author

@patrixr one to finish off perhaps? Not sure which branch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants