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

CRM-21838 strip html tags from alerts when crm-notification-container div is not present #11797

Merged
merged 1 commit into from
Mar 16, 2018

Conversation

hoegrammer
Copy link
Contributor

@hoegrammer hoegrammer commented Mar 11, 2018

Strips html from CRM.alert when falling back to alert()

Overview

In certain contexts CRM.alert() falls back to using the standard JS alert() which does not parse HTML. So if there is any HTML in the text passed to CRM.alert() this change strips it out.

Before

Sometimes in a customised context the alert will show as a standard alert but with html in an the html tags will display as literals

After

It renders as plan text

Technical Details

When crm-notification-container div is not present it falls back to standard html. This PR alters the html in the part of the code that applies during fallback to strip html tags. Fallback occurs on a drupal page (in this example)

Comments

Anything else you would like the reviewer to note


@civicrm-builder
Copy link

Can one of the admins verify this patch?

@hoegrammer hoegrammer changed the title Fix for https://issues.civicrm.org/jira/browse/CRM-21838 Fix for CRM-21838 Mar 11, 2018
@eileenmcnaughton eileenmcnaughton changed the title Fix for CRM-21838 CRM-21838 strip html tags from alerts as they are not parsed in standard alerts Mar 11, 2018
@eileenmcnaughton
Copy link
Contributor

@colemanw wanna look at this?

@eileenmcnaughton
Copy link
Contributor

test this please

@seamuslee001
Copy link
Contributor

@hoegrammer Naomi the test failures look legit for this PR, it looks like the fix may not work in an Angular JS context. If you have built your civicrm instance with buildkit you maybe able to run civi-test-run -b <your build name> -j <file path to log file> karma to replicate the tests being run on the server

@eileenmcnaughton
Copy link
Contributor

It's probably also worth giving more details as to how to replicate this issue & when it arises for you (screenshots might help)

@hoegrammer
Copy link
Contributor Author

@eileenmcnaughton I am using a Drupal dashboard module called Homebox which displays blocks on the homepage. I am using it to display some Drupal views listing activities. You can click on an activity in the list and it will open in a popup (did this by adding the class "crm-popup" when rewriting the field). The idea is for the user to have a quick look at the activity and then file it on a case using the File On Case button. This is so they can go through the list and file away the activities without having to navigate away from the dashboard. It works really well except that the message that comes up saying "Filed on case such-and-such" contains a link to the case. Because there is no crm-notification-container on the page, the CRM.alert falls back to normal alert and therefore shows the uninterpreted html.

@hoegrammer
Copy link
Contributor Author

@seamuslee001 I did not use buildkit but I have had a look at the test results and it looks like the call DOMParser is the problem. I've since discovered there is a neater way to do it just with jQuery and I think this will work better. If it fails again I will look at using buildkit

@eileenmcnaughton
Copy link
Contributor

So we need to ONLY strip the html on fallback

@hoegrammer
Copy link
Contributor Author

@eileenmcnaughton yep, that's what the PR does

@seamuslee001
Copy link
Contributor

Jenkins test this please

@eileenmcnaughton eileenmcnaughton changed the title CRM-21838 strip html tags from alerts as they are not parsed in standard alerts CRM-21838 strip html tags from alerts when crm-notification-container div is not present Mar 12, 2018
@eileenmcnaughton
Copy link
Contributor

OK- that makes sense - I 've updated the pr description now. Can you squash the 2 commits into one.

I do kinda want @colemanw to eyeball this - although @seamuslee001 might feel confident enough to merge this one as he is pretty strong on this side of the code too.

@hoegrammer
Copy link
Contributor Author

Squashed.

@eileenmcnaughton
Copy link
Contributor

jenkins add to whitelist

@colemanw
Copy link
Member

This looks great to me. Neat trick using jQuery.

@colemanw colemanw merged commit c879593 into civicrm:master Mar 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants