diff options
author | Marvin W <git@larma.de> | 2020-06-27 11:23:48 +0200 |
---|---|---|
committer | Marvin W <git@larma.de> | 2020-06-28 11:53:43 +0200 |
commit | 48964bc5cca6e56cd7fc745b1a4a9ae5d34f0772 (patch) | |
tree | 8800df708651f4c7b1628f147b5441560f67218e /xmpp-vala | |
parent | 8f8018ec81d4ea6e6a5e2f3d811daa57a31f6122 (diff) | |
download | dino-48964bc5cca6e56cd7fc745b1a4a9ae5d34f0772.tar.gz dino-48964bc5cca6e56cd7fc745b1a4a9ae5d34f0772.zip |
Don't strip() at XML layer
Diffstat (limited to 'xmpp-vala')
-rw-r--r-- | xmpp-vala/src/core/stanza_reader.vala | 15 | ||||
-rw-r--r-- | xmpp-vala/tests/stanza.vala | 2 |
2 files changed, 11 insertions, 6 deletions
diff --git a/xmpp-vala/src/core/stanza_reader.vala b/xmpp-vala/src/core/stanza_reader.vala index 1727847d..0c07948d 100644 --- a/xmpp-vala/src/core/stanza_reader.vala +++ b/xmpp-vala/src/core/stanza_reader.vala @@ -221,7 +221,7 @@ public class StanzaReader { var res = new StanzaNode(); res.name = "#text"; 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; } @@ -244,8 +244,9 @@ public class StanzaReader { var res = yield read_node_start(); if (res.has_nodes) { bool finish_node_seen = false; + StanzaNode? text_node = null; do { - yield skip_until_non_ws(); + text_node = yield read_text_node(); if ((yield peek_single()) == '<') { skip_single(); if ((yield peek_single()) == '/') { @@ -264,11 +265,15 @@ public class StanzaReader { } else { res.sub_nodes.add(yield read_stanza_node()); } - } else { - res.sub_nodes.add(yield read_text_node()); } } 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(); return res; diff --git a/xmpp-vala/tests/stanza.vala b/xmpp-vala/tests/stanza.vala index 19baef49..17cd8317 100644 --- a/xmpp-vala/tests/stanza.vala +++ b/xmpp-vala/tests/stanza.vala @@ -37,7 +37,7 @@ class StanzaTest : Gee.TestCase { <message from='laurence@example.net/churchyard' to='juliet@example.com' 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> </stream:stream> """; |