sombhardwaj / asmack

Automatically exported from code.google.com/p/asmack
0 stars 0 forks source link

Parser fails to process SimplePayload content in pubsub items #24

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What are you doing to produce the error?
1. I first insert an item with a SimplePayload with an XML format (as indicated 
in the smack API doc)
2. Then I get the items from the node, with the payload.

What is the expected output?

I would obtain the same payload I posted just before.

What do you see instead? (Please attach a debug enabled logcat)

I obtain a payload where all the XML tags are replaced by null. (with the 
method SimplePayload.toXML())

Here is an example : 

Posted payload :

<entry xmlns="http://www.w3.org/2005/Atom"><author>Paulo</author><content>La 
décision sera prise par le Bureau d'enquête et d'analyses...</content></entry>

Received payload (after parsing process by smack):

nullnullPaulonullnullLa décision sera prise par le Bureau d'enquête et 
d'analyses...nullnull

This issue occurs only with asmack, in a smack java program it works fine. I 
have verified that the server sends the good stanzas, it is ok. The problem 
comes from the parser I think. I have seen that asmack makes some changes in 
the parser used, but I do not find where the tags are replaced by null.

What version of aSmack / Android / Device do you use?

aSmack: from trunk on github
android : android 1.6 (fails with all devices running 1.6, I did not test with 
other version)

What server do you use? Is there a public server to reproduce the problem?

openfire from svn

What else might help us to reproduce and hunt down the problem?

I do not know, I spent hours to check the source code, but I failed...

Thanks in advance,

Paulo

Original issue reported on code.google.com by pg.ens...@gmail.com on 23 Jun 2010 at 3:04

GoogleCodeExporter commented 8 years ago
I find the reason, but not the solution.

In asmack there is a patch that replaces all instances of MXParser by an 
instance of a Parser returned by XMLPullFactory. This instance is actually an 
instance of KXmlParser. MXParser and KXmlParser both implement XmlPullParser 
interface but in reality they do not have the same behavior. When getText() is 
used and the next element is a TAG, MKParser returns a string containing the 
TAG, but KXmlParser returns null (after a check to the interface doc, the 
correct behavior is to return null).

At this time I have no solution, I am trying to use KXmlParser to obtain the 
wanted behavior. After all, this is the MXParser used in smack that does not 
respect the interface spec.

I do not know how use XmlPullParser, so if someone wants to help me, thanks in 
advance :) The problem is in the file 
org.jivesoftware.smackx.pubsub.provider.ItemProvider.java

Paulo

Original comment by pg.ens...@gmail.com on 24 Jun 2010 at 3:44

GoogleCodeExporter commented 8 years ago
Could you post the corresponding XML? Thanks in advance....

Original comment by rtreffer@gmail.com on 26 Aug 2010 at 7:16

GoogleCodeExporter commented 8 years ago
The corresponding XML is posted in the first message, with the result of the 
parsing. It fails with all XML I tried. If you want another peace of XML, do 
not hesitate to tell me.

I found a solution to make it work for me, but I am not sure this is very 
clean. I post the code in attached files.

Paulo

Original comment by pg.ens...@gmail.com on 26 Aug 2010 at 7:52

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks for the fix!!!

Original comment by hur...@gmail.com on 14 Mar 2012 at 8:49

GoogleCodeExporter commented 8 years ago
Hello guys,
thanks for the solution, this is great!
Attached you find "my version" of the fix.
In addition to the previous fix, in includes the "node" attribute and the 
"xmlns" of the paylods root element.
regards
sni

Original comment by stefan.n...@gmail.com on 4 Jun 2012 at 7:21

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Fixed in aSmack 0.8.1: See https://github.com/Flowdalic/asmack/issues/3

Filled as upstream bug 
[SMACK-415|http://issues.igniterealtime.org/browse/SMACK-415]

Original comment by fschm...@gmail.com on 19 Feb 2013 at 10:56