Merge lp:~widelands-dev/widelands/bug-1795570-chat-br-tags into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 8881
Proposed branch: lp:~widelands-dev/widelands/bug-1795570-chat-br-tags
Merge into: lp:widelands
Diff against target: 45 lines (+11/-3)
1 file modified
src/wui/chat_msg_layout.cc (+11/-3)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1795570-chat-br-tags
Reviewer Review Type Date Requested Status
Notabilis diff, testing Approve
Review via email: mp+356653@code.launchpad.net

Commit message

Fix br tag in chat server help message

To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4118. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/440588155.
Appveyor build 3915. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1795570_chat_br_tags-3915.

Revision history for this message
Notabilis (notabilis27) wrote :

Diff is looking good and /help is printed correctly.
Just as a side note since your commit messages indicate otherwise: This also affects all chat messages of users, e.g., I can send "line1<br>line2" and it is printed in two lines. If that is intentionally (or at least acceptable), then this can be merged.

review: Approve (diff, testing)
Revision history for this message
GunChleoc (gunchleoc) wrote :

I didn't think of that, but I also see no harm in it. If somebody wants to get some lolz out of it, it will be pretty harmless.

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/wui/chat_msg_layout.cc'
2--- src/wui/chat_msg_layout.cc 2018-08-20 19:00:20 +0000
3+++ src/wui/chat_msg_layout.cc 2018-10-12 10:30:39 +0000
4@@ -19,6 +19,7 @@
5
6 #include "wui/chat_msg_layout.h"
7
8+#include <boost/algorithm/string.hpp>
9 #include <boost/format.hpp>
10
11 #include "chat/chat.h"
12@@ -39,6 +40,13 @@
13 return "999999";
14 }
15
16+std::string sanitize_message(const std::string& given_text) {
17+ std::string result = richtext_escape(given_text);
18+ // Preserve br tag
19+ boost::replace_all(result, "&lt;br&gt;", "<br>");
20+ return result;
21+}
22+
23 } // namespace
24
25 // Returns a richtext string that can be displayed to the user.
26@@ -46,7 +54,7 @@
27 const std::string& font_face = "serif";
28 std::string message = "<p><font color=33ff33 size=9>";
29
30- std::string sanitized = richtext_escape(chat_message.msg);
31+ const std::string sanitized = sanitize_message(chat_message.msg);
32
33 // time calculation
34 char ts[13];
35@@ -57,8 +65,8 @@
36 color(chat_message.playern))
37 .str();
38
39- std::string sender_escaped = richtext_escape(chat_message.sender);
40- std::string recipient_escaped = richtext_escape(chat_message.recipient);
41+ const std::string sender_escaped = richtext_escape(chat_message.sender);
42+ const std::string recipient_escaped = richtext_escape(chat_message.recipient);
43
44 if (chat_message.recipient.size() && chat_message.sender.size()) {
45 // Personal message handling

Subscribers

People subscribed via source and target branches

to status/vote changes: