Properly encode HTML entities for chat's last message
This commit is contained in:
parent
204966e265
commit
e4dbb63a92
4 changed files with 22 additions and 3 deletions
|
@ -17,7 +17,7 @@ PhotoTextsListItem {
|
||||||
// last user
|
// last user
|
||||||
prologSecondaryText.text: is_channel ? "" : ( last_message_sender_id ? ( last_message_sender_id !== ownUserId ? Emoji.emojify(Functions.getUserName(tdLibWrapper.getUserInformation(last_message_sender_id)), primaryText.font.pixelSize) : qsTr("You") ) : qsTr("Unknown") )
|
prologSecondaryText.text: is_channel ? "" : ( last_message_sender_id ? ( last_message_sender_id !== ownUserId ? Emoji.emojify(Functions.getUserName(tdLibWrapper.getUserInformation(last_message_sender_id)), primaryText.font.pixelSize) : qsTr("You") ) : qsTr("Unknown") )
|
||||||
// last message
|
// last message
|
||||||
secondaryText.text: last_message_text ? Emoji.emojify(last_message_text, Theme.fontSizeExtraSmall, emojiBase) : qsTr("Unknown")
|
secondaryText.text: last_message_text ? Emoji.emojify(Functions.enhanceHtmlEntities(last_message_text), Theme.fontSizeExtraSmall, emojiBase) : qsTr("Unknown")
|
||||||
// message date
|
// message date
|
||||||
tertiaryText.text: ( last_message_date ? Functions.getDateTimeElapsed(last_message_date) : qsTr("Unknown") ) + Emoji.emojify(last_message_status, tertiaryText.font.pixelSize)
|
tertiaryText.text: ( last_message_date ? Functions.getDateTimeElapsed(last_message_date) : qsTr("Unknown") ) + Emoji.emojify(last_message_status, tertiaryText.font.pixelSize)
|
||||||
unreadCount: unread_count
|
unreadCount: unread_count
|
||||||
|
|
|
@ -160,7 +160,7 @@ ChatInformationTabItemBase {
|
||||||
onChatChanged: {
|
onChatChanged: {
|
||||||
if (changedChatId === chat_id) {
|
if (changedChatId === chat_id) {
|
||||||
// Force update of some list item elements (currently only last message text seems to create problems). dataChanged() doesn't seem to trigger them all :(
|
// Force update of some list item elements (currently only last message text seems to create problems). dataChanged() doesn't seem to trigger them all :(
|
||||||
secondaryText.text = last_message_text ? Emoji.emojify(last_message_text, Theme.fontSizeExtraSmall, "../../js/emoji/") : qsTr("Unknown")
|
secondaryText.text = last_message_text ? Emoji.emojify(Functions.enhanceHtmlEntities(last_message_text), Theme.fontSizeExtraSmall, "../../js/emoji/") : qsTr("Unknown")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,6 +226,25 @@ function handleHtmlEntity(messageText, messageInsertions, originalString, replac
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function enhanceHtmlEntities(simpleText) {
|
||||||
|
|
||||||
|
var messageInsertions = [];
|
||||||
|
var messageText = simpleText;
|
||||||
|
|
||||||
|
handleHtmlEntity(messageText, messageInsertions, "&", "&");
|
||||||
|
handleHtmlEntity(messageText, messageInsertions, "<", "<");
|
||||||
|
handleHtmlEntity(messageText, messageInsertions, ">", ">");
|
||||||
|
|
||||||
|
messageInsertions.sort( function(a, b) { return (b.offset+b.removeLength) - (a.offset+a.removeLength) } );
|
||||||
|
|
||||||
|
for (var z = 0; z < messageInsertions.length; z++) {
|
||||||
|
messageText = messageText.substring(0, messageInsertions[z].offset) + messageInsertions[z].insertionString + messageText.substring(messageInsertions[z].offset + messageInsertions[z].removeLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
return messageText;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function enhanceMessageText(formattedText) {
|
function enhanceMessageText(formattedText) {
|
||||||
|
|
||||||
var messageInsertions = [];
|
var messageInsertions = [];
|
||||||
|
|
|
@ -245,7 +245,7 @@ Page {
|
||||||
onChatChanged: {
|
onChatChanged: {
|
||||||
if (overviewPage.chatListCreated && changedChatId === chat_id) {
|
if (overviewPage.chatListCreated && changedChatId === chat_id) {
|
||||||
// Force update of some list item elements (currently only last message text seems to create problems). dataChanged() doesn't seem to trigger them all :(
|
// Force update of some list item elements (currently only last message text seems to create problems). dataChanged() doesn't seem to trigger them all :(
|
||||||
secondaryText.text = last_message_text ? Emoji.emojify(last_message_text, Theme.fontSizeExtraSmall) : qsTr("Unknown")
|
secondaryText.text = last_message_text ? Emoji.emojify(Functions.enhanceHtmlEntities(last_message_text), Theme.fontSizeExtraSmall) : qsTr("Unknown")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue