No more missing text when converting IRC colors to xhtml-im

fix #2496
This commit is contained in:
Florent Le Coz
2014-04-17 20:37:46 +02:00
parent 9683f0a0b2
commit bd7936bdfe
2 changed files with 5 additions and 1 deletions
+1 -1
View File
@@ -71,7 +71,7 @@ Xmpp::body irc_format_to_xhtmlim(const std::string& s)
const std::string txt = s.substr(pos_start, pos_end-pos_start); const std::string txt = s.substr(pos_start, pos_end-pos_start);
cleaned += txt; cleaned += txt;
if (current_node->has_children()) if (current_node->has_children())
current_node->get_last_child()->set_tail(txt); current_node->get_last_child()->add_to_tail(txt);
else else
current_node->set_inner(txt); current_node->set_inner(txt);
+4
View File
@@ -144,6 +144,10 @@ int main()
std::tie(cleaned_up, xhtml) = irc_format_to_xhtmlim(","); std::tie(cleaned_up, xhtml) = irc_format_to_xhtmlim(",");
assert(xhtml && !xhtml->has_children() && cleaned_up.empty()); assert(xhtml && !xhtml->has_children() && cleaned_up.empty());
std::tie(cleaned_up, xhtml) = irc_format_to_xhtmlim("[\x1D13dolphin-emu/dolphin\x1D] 03foo commented on #283 (Add support for the guide button to XInput): 02http://example.com");
assert(xhtml->to_string() == "<body xmlns='http://www.w3.org/1999/xhtml'>[<span style='font-style:italic;'/><span style='font-style:italic;color:lightmagenta;'>dolphin-emu/dolphin</span><span style='color:lightmagenta;'>] </span><span style='color:green;'>foo</span> commented on #283 (Add support for the guide button to XInput): <span style='text-decoration:underline;'/><span style='text-decoration:underline;color:blue;'>http://example.com</span><span style='text-decoration:underline;'/></body>");
assert(cleaned_up == "[dolphin-emu/dolphin] foo commented on #283 (Add support for the guide button to XInput): http://example.com");
/** /**
* JID parsing * JID parsing
*/ */