Fix recognition of namespace in extension handlers

Description

This patch fixes an issue in the recognition of extension handlers. The old code assumed that the namespace for the given extension would always be handled by the xmlns attribute of the root element. However, you are not guarunteed that the namespace attribute will not be prefixed by some servers and clients. The more reliable way in to rely on the Actionscript XML API to get the namespace.

— C:/Documents and Settings/rn996/workspace/xiff_as3_flexlib_beta1/src/org/jivesoftware/xiff/data/XMPPStanza.as (revision 5480)
+++ C:/Documents and Settings/rn996/workspace/xiff_as3_flexlib_beta1/src/org/jivesoftware/xiff/data/XMPPStanza.as (working copy)
@@ -141,8 +141,12 @@
{
var nName:String = children[i].nodeName;
- var nNamespace:String = children[i].attributes.xmlns;
+ // Namespace handling should be done by using AS2's XML api.
+ // Assuming XML attribute names will break against servers that
+ // prefix namespaces in the generated XML.
+ var nNamespace:String = XMLNode(children[i]).namespaceURI;
+
nNamespace = exists( nNamespace ) ? nNamespace : CLIENT_NS;
if( nName == "error" ) {

Message was edited by: RyanNorris

Environment

None

Activity

Show:

Juga Paazmaya 
August 2, 2012 at 10:04 PM

While XML migration, the namespace handling has been rewritten.

alberto 
November 14, 2008 at 4:52 AM

I encountered the problem of namespaces with prefixes. I modified the deserialize function in the XMPPStanza class. The modification is assuming that there is only one namespace among all the namespaces representing an extension in a given XML node. It was successfully tested using FlexBuilder 3.0 (AS 3.0). See my modifications below:
.....
var nNamespace: String = children[i].attributes.xmlns;

//alberto acevedo 11/13//2008
//start adding
//Look for namespaces with prefixes having a registered extension class
for each (var attr: Object in children[i].attributes)
{
if (ExtensionClassREgistry.lookup(attr.toString()))
{
nNamespace = String(attr);
break;
}
}
// end adding

...
...
nNamespace = exists(nNamespace)?nNamespace: CLIENT_NS;

Thanks,

Alberto Acevedo

Sean Voisen 
May 8, 2007 at 2:28 AM

Need to reinvestigate to use AS3's namespace handling.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created December 17, 2006 at 10:19 AM
Updated October 28, 2020 at 8:51 AM
Resolved August 2, 2012 at 10:04 PM