Recently I've set up a jabberd 1.4.2 server.
I've discovered that with jabberd-1.4.2 and jud-0.4, JUD searches sent from the Psi client don't work while searches from the Exodus client work fine.
I've decided to investigate the problem and found out that Psi sends its query in a form similar to this:
<iq type="set" id="aabca" to="jud.office.altkom.com.pl" >
<query xmlns="jabber:iq:search" >
<name></name>
<first></first>
<last></last>
<nick>d</nick>
<email></email> </query></iq>
While Exodus sends its queries with all search terms on one line:
<iq id="jcl_10" to="jud.office.altkom.com.pl" type="set"><query xmlns="jabber:iq:search"><nick>d</nick></qu
ery></iq>
The Psi searches always return 0 results, probably due to a bug in XML parser used in jabber 1.4.2.
Look at jud_search.c from jud-0.4: for empty query elements, the data that jud_search_walk() receives from xmlnode_get_data() function contain a newline and 2 spaces when Psi is the source of a query!
Indeed, the query from Psi contains a newline and 2 spaces, but not inside search term elements, but before them!
I've made a workaround patch that causes the jud module to skip any leading spaces, newlines or tabs in the data string received from xmlnode_get_data() function. I've tested my patch - now searching from Psi works fine on my server :)
I'm attaching the patch to this message.
Best Regards,
--
Olo
GG#: 274614
ICQ UIN: 19780575
http://olo.office.altkom.com.pl
diff -urN jud-0.4/jud_search.c jud-0.4.olo/jud_search.c
--- jud-0.4/jud_search.c Thu Feb 1 10:46:54 2001
+++ jud-0.4.olo/jud_search.c Mon Dec 9 17:19:54 2002
@@ -39,6 +39,8 @@
int flag_searched = 0;
int flag_mismatch = 0;
char *data;
+ char *normalizeddata;
+ char message[MAX_LOG_SIZE];
for(term = xmlnode_get_firstchild(p->iq); term != NULL; term =
xmlnode_get_nextsibling(term))
{
@@ -46,7 +48,24 @@
flag_searched = 1;
-
if(j_strncasecmp(data,xmlnode_get_tag_data(cur,xmlnode_get_name(term)),strlen(data))
!= 0)
+ /* Strip initial whitespace characters to workaround
+ * a bug in XML parser where empty elements
+ * on a line with initial whitespaces would
+ * receive those whitespaces in their content
+ */
+ for (normalizeddata = data;
+ *normalizeddata != '\0' &&
+ *normalizeddata == '\t' ||
+ *normalizeddata == '\n' ||
+ *normalizeddata == ' '
+ ;
+ normalizeddata++)
+ ;
+ data = normalizeddata;
+
+ if( (strlen(data) > 0) &&
+
+(j_strncasecmp(data,xmlnode_get_tag_data(cur,xmlnode_get_name(term)),strlen(data)) !=
+0)
+ )
flag_mismatch = 1;
}
