Don't strip() at XML layer
This commit is contained in:
parent
8f8018ec81
commit
48964bc5cc
|
@ -333,7 +333,9 @@ public class MessageProcessor : StreamInteractionModule, Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Entities.Message parse_message_stanza(Account account, Xmpp.MessageStanza message) {
|
public async Entities.Message parse_message_stanza(Account account, Xmpp.MessageStanza message) {
|
||||||
Entities.Message new_message = new Entities.Message(message.body);
|
string? body = message.body;
|
||||||
|
if (body != null) body = body.strip();
|
||||||
|
Entities.Message new_message = new Entities.Message(body);
|
||||||
new_message.account = account;
|
new_message.account = account;
|
||||||
new_message.stanza_id = Xep.UniqueStableStanzaIDs.get_origin_id(message) ?? message.id;
|
new_message.stanza_id = Xep.UniqueStableStanzaIDs.get_origin_id(message) ?? message.id;
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,7 @@ public class StanzaReader {
|
||||||
var res = new StanzaNode();
|
var res = new StanzaNode();
|
||||||
res.name = "#text";
|
res.name = "#text";
|
||||||
res.ns_uri = ns_state.current_ns_uri;
|
res.ns_uri = ns_state.current_ns_uri;
|
||||||
res.encoded_val = (yield read_until_char('<')).strip();
|
res.encoded_val = (yield read_until_char('<'));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,8 +244,9 @@ public class StanzaReader {
|
||||||
var res = yield read_node_start();
|
var res = yield read_node_start();
|
||||||
if (res.has_nodes) {
|
if (res.has_nodes) {
|
||||||
bool finish_node_seen = false;
|
bool finish_node_seen = false;
|
||||||
|
StanzaNode? text_node = null;
|
||||||
do {
|
do {
|
||||||
yield skip_until_non_ws();
|
text_node = yield read_text_node();
|
||||||
if ((yield peek_single()) == '<') {
|
if ((yield peek_single()) == '<') {
|
||||||
skip_single();
|
skip_single();
|
||||||
if ((yield peek_single()) == '/') {
|
if ((yield peek_single()) == '/') {
|
||||||
|
@ -264,11 +265,15 @@ public class StanzaReader {
|
||||||
} else {
|
} else {
|
||||||
res.sub_nodes.add(yield read_stanza_node());
|
res.sub_nodes.add(yield read_stanza_node());
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
res.sub_nodes.add(yield read_text_node());
|
|
||||||
}
|
}
|
||||||
} while (!finish_node_seen);
|
} while (!finish_node_seen);
|
||||||
if (res.sub_nodes.size == 0) res.has_nodes = false;
|
if (res.sub_nodes.size == 0) {
|
||||||
|
if (text_node == null || text_node.val.length == 0) {
|
||||||
|
res.has_nodes = false;
|
||||||
|
} else {
|
||||||
|
res.sub_nodes.add(text_node);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ns_state = ns_state.pop();
|
ns_state = ns_state.pop();
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -37,7 +37,7 @@ class StanzaTest : Gee.TestCase {
|
||||||
<message from='laurence@example.net/churchyard'
|
<message from='laurence@example.net/churchyard'
|
||||||
to='juliet@example.com'
|
to='juliet@example.com'
|
||||||
xml:lang='en'>
|
xml:lang='en'>
|
||||||
<body>I'll send a friar with speed, to Mantua, with my letters to thy lord.</body>
|
<body> I'll send a friar with speed, to Mantua, with my letters to thy lord.</body>
|
||||||
</message>
|
</message>
|
||||||
</stream:stream>
|
</stream:stream>
|
||||||
""";
|
""";
|
||||||
|
|
Loading…
Reference in a new issue