[Pkg-javascript-commits] [ltx] 18/469: insert <stream:stream> xmlns for each stanza
Jonas Smedegaard
dr at jones.dk
Wed Aug 31 13:00:52 UTC 2016
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository ltx.
commit 8e30316069792042a8dea8104e1bc562654d8f49
Author: Astro <astro at spaceboyz.net>
Date: Sun May 30 19:30:28 2010 +0200
insert <stream:stream> xmlns for each stanza
---
lib/xmpp/connection.js | 28 +++++++++++++++++++++++-----
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/lib/xmpp/connection.js b/lib/xmpp/connection.js
index af14f8f..05a732b 100644
--- a/lib/xmpp/connection.js
+++ b/lib/xmpp/connection.js
@@ -25,10 +25,19 @@ exports.Connection = Connection;
Connection.prototype.send = function(stanza) {
var self = this;
- if (stanza.root)
- stanza.root().write(function(s) {
- self.write(s);
- });
+ if (stanza.root) {
+ var el = stanza.root();
+ /* Remove superfluous xmlns that were aleady declared in
+ <stream:stream> */
+ for(var k in self.streamAttrs) {
+ if ((k == 'xmlns' ||
+ k.substr(0, 6) == 'xmlns:') &&
+ el.attrs[k] == this.streamAttrs[k])
+ el.attrs[k] = self.streamAttrs[k]
+ }
+
+ el.write(function(s) { self.write(s); });
+ }
else
self.write(stanza);
};
@@ -44,9 +53,18 @@ Connection.prototype.startParser = function() {
} else {
var child = new xml.Element(name, attrs);
if (!self.element) {
- /* TODO: add stream xmlns */
+ /* Add stream xmlns, so the user can check for
+ 'jabber:client' etc. */
+ for(var k in self.streamAttrs) {
+ if ((k == 'xmlns' ||
+ k.substr(0, 6) == 'xmlns:') &&
+ !child.attrs[k])
+ child.attrs[k] = self.streamAttrs[k]
+ }
+ /* A new stanza */
self.element = child;
} else {
+ /* A child element of a stanza */
self.element = self.element.cnode(child);
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/ltx.git
More information about the Pkg-javascript-commits
mailing list