MDL-56252 message: clean message text in message area

Remove the HTML tags from any message in the message area when updating
the last message on the contact otherwise the styling breaks and also
allows <script> tags to be added to the page.
This commit is contained in:
Ryan Wyllie
2016-10-20 06:49:26 +00:00
parent 6a69cda97d
commit 54d83992b4
6 changed files with 13 additions and 2 deletions
File diff suppressed because one or more lines are too long
+3
View File
@@ -546,6 +546,9 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* @return {String} The altered text
*/
Contacts.prototype._getContactText = function(text) {
// Remove the HTML tags to render the contact text.
text = $(document.createElement('div')).html(text).text();
if (text.length > this._messageLength) {
text = text.substr(0, this._messageLength - 3);
text += '...';
+2 -1
View File
@@ -147,7 +147,8 @@ class helper {
$data->messageid = null;
if (isset($contact->smallmessage)) {
$data->ismessaging = true;
$data->lastmessage = $contact->smallmessage;
// Strip the HTML tags from the message for displaying in the contact area.
$data->lastmessage = clean_param($contact->smallmessage, PARAM_NOTAGS);
$data->useridfrom = $contact->useridfrom;
if (isset($contact->messageid)) {
$data->messageid = $contact->messageid;
+2
View File
@@ -473,6 +473,8 @@
position: relative;
.text {
display: block;
p {
margin: 0;
}
@@ -465,6 +465,8 @@
position: relative;
.text {
display: block;
p {
margin: 0;
}
+3
View File
@@ -6190,6 +6190,9 @@ a.ygtvspacer:hover {
border-radius: 4px;
position: relative;
}
.messaging-area-container .messaging-area .messages-area .messages .message .content .text {
display: block;
}
.messaging-area-container .messaging-area .messages-area .messages .message .content .text p {
margin: 0;
}