aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp-vala/src')
-rw-r--r--xmpp-vala/src/core/stanza_node.vala3
-rw-r--r--xmpp-vala/src/core/stanza_reader.vala56
2 files changed, 40 insertions, 19 deletions
diff --git a/xmpp-vala/src/core/stanza_node.vala b/xmpp-vala/src/core/stanza_node.vala
index 0544cc1f..6ef3f0aa 100644
--- a/xmpp-vala/src/core/stanza_node.vala
+++ b/xmpp-vala/src/core/stanza_node.vala
@@ -333,6 +333,9 @@ public class StanzaNode : StanzaEntry {
internal string printf(int i, string fmt_start_begin, string start_empty_end, string start_content_end, string fmt_end, string fmt_attr, bool no_ns = false) {
string indent = string.nfill (i * 2, ' ');
if (name == "#text") {
+ if (((!)val).length > 1000) {
+ return indent + "[... retracted for brevity ...]\n";
+ }
return indent + ((!)val).replace("\n", indent + "\n") + "\n";
}
var sb = new StringBuilder();
diff --git a/xmpp-vala/src/core/stanza_reader.vala b/xmpp-vala/src/core/stanza_reader.vala
index 72aa0b5f..c90390b5 100644
--- a/xmpp-vala/src/core/stanza_reader.vala
+++ b/xmpp-vala/src/core/stanza_reader.vala
@@ -63,14 +63,14 @@ public class StanzaReader {
if (buffer_pos >= buffer_fill) {
yield update_buffer();
}
- char c = (char) buffer[buffer_pos++];
- return c;
+ return (char) buffer[buffer_pos++];
}
private async char peek_single() throws XmlError {
- var res = yield read_single();
- buffer_pos--;
- return res;
+ if (buffer_pos >= buffer_fill) {
+ yield update_buffer();
+ }
+ return (char) buffer[buffer_pos];
}
private bool is_ws(uint8 what) {
@@ -82,37 +82,55 @@ public class StanzaReader {
}
private async void skip_until_non_ws() throws XmlError {
- while (is_ws(yield peek_single())) {
- skip_single();
+ if (buffer_pos >= buffer_fill) {
+ yield update_buffer();
+ }
+ while (is_ws(buffer[buffer_pos])) {
+ buffer_pos++;
+ if (buffer_pos >= buffer_fill) {
+ yield update_buffer();
+ }
}
}
private async string read_until_ws() throws XmlError {
var res = new StringBuilder();
- var what = yield peek_single();
- while (!is_ws(what)) {
- res.append_c(yield read_single());
- what = yield peek_single();
+ if (buffer_pos >= buffer_fill) {
+ yield update_buffer();
+ }
+ while (!is_ws(buffer[buffer_pos])) {
+ res.append_c((char) buffer[buffer_pos++]);
+ if (buffer_pos >= buffer_fill) {
+ yield update_buffer();
+ }
}
return res.str;
}
private async string read_until_char_or_ws(char x, char y = 0) throws XmlError {
var res = new StringBuilder();
- var what = yield peek_single();
- while (what != x && what != y && !is_ws(what)) {
- res.append_c(yield read_single());
- what = yield peek_single();
+ if (buffer_pos >= buffer_fill) {
+ yield update_buffer();
+ }
+ while (buffer[buffer_pos] != x && buffer[buffer_pos] != y && !is_ws(buffer[buffer_pos])) {
+ res.append_c((char) buffer[buffer_pos++]);
+ if (buffer_pos >= buffer_fill) {
+ yield update_buffer();
+ }
}
return res.str;
}
private async string read_until_char(char x) throws XmlError {
var res = new StringBuilder();
- var what = yield peek_single();
- while (what != x) {
- res.append_c(yield read_single());
- what = yield peek_single();
+ if (buffer_pos >= buffer_fill) {
+ yield update_buffer();
+ }
+ while (buffer[buffer_pos] != x) {
+ res.append_c((char) buffer[buffer_pos++]);
+ if (buffer_pos >= buffer_fill) {
+ yield update_buffer();
+ }
}
return res.str;
}