Commit 6a9b5677 authored by Robert Lyon's avatar Robert Lyon

Bug 1520011: Notifications displaying incorrectly

If we have special chars like " or > in a feedback message they get
saved to db as htmlspecialchars like " or $gt;

When we go to display them we turn the & part into a specialchar again
leading to bad display.

Change-Id: Ie66dd599029f0939938f0d1d829c4156b5db6d56
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 96c5d641
......@@ -1413,6 +1413,8 @@ abstract class ActivityTypePlugin extends ActivityType {
function format_notification_whitespace($message, $type=null) {
$message = preg_replace('/<br( ?\/)?>/', '', $message);
$message = preg_replace('/^(\s|&nbsp;|\xc2\xa0)*/', '', $message);
// convert any htmlspecialchars back so we don't double escape as part of format_whitespace()
$message = htmlspecialchars_decode($message);
$message = format_whitespace($message);
// @todo: Sensibly distinguish html notifications, notifications where the full text
// appears on another page and this is just an abbreviated preview, and text-only
......
......@@ -11,15 +11,21 @@ Background:
| userB | Kupuhipa1 | test02@example.com | Barry | Bishop | mahara | internal | member |
| userC | Kupuhipa1 | test03@example.com | Catriona | Carson | mahara | internal | member |
Scenario: Selecting select2 option via ajax
Scenario: Selecting select2 option via ajax (Bug #1520011)
# Log in as an Admin user
Given I log in as "admin" with password "Kupuhipa1"
# Checking messages
# Send a message
And I follow "mail"
And I follow "Compose"
And I fill in select2 input "sendmessage_recipients" with "userA" and select "Andrea Andrews (userA)"
And I set the following fields to these values:
| Subject | Test message |
| Message | This is a test |
| Subject | Test message with < & > |
| Message | This is a test with > & < |
And I press "Send message"
Then I should see "Message sent"
\ No newline at end of file
Then I should see "Message sent"
# Checking message
When I follow "Sent"
And I follow "Test message"
Then I should see "Test message with < & >"
And I should see "This is a test with > & <"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment