igniterealtime / openfire-search-plugin

Adds Jabber Search (XEP-0055) capabilities to Openfire
Apache License 2.0
3 stars 8 forks source link

Search Results are not valid according to XEP-0055 #11

Open hamzaozturk opened 3 years ago

hamzaozturk commented 3 years ago
<iq type='set'
    from='romeo@montague.net/home'
    to='characters.shakespeare.lit'
    id='search2'
    xml:lang='en'>
  <query xmlns='jabber:iq:search'>
    <first>Juliet</first>
  </query>
</iq>

If i send this stanza to the server, it gives response like below:

<iq type='result'
    from='characters.shakespeare.lit'
    to='romeo@montague.net/home'
    id='search2'
    xml:lang='en'>
  <query xmlns='jabber:iq:search'>
    <item jid='juliet@capulet.com'>
      <first>Juliet Capulet</first>
    </item>
  </query>
</iq>

However, according to the XEP-0055, it should give like this:

<iq type='result'
    from='characters.shakespeare.lit'
    to='romeo@montague.net/home'
    id='search2'
    xml:lang='en'>
  <query xmlns='jabber:iq:search'>
    <item jid='juliet@capulet.com'>
      <first>Juliet</first>
      <last>Capulet</last>
      <nick>JuliC</nick>
      <email>juliet@shakespeare.lit</email>
    </item>
  </query>
</iq>

It looks like, mapping all fields to the name causes to this issue.

https://github.com/igniterealtime/openfire-search-plugin/blob/8c1747b5f5f6b1eef2a1e6a77205489ee33faa8a/src/java/org/jivesoftware/openfire/plugin/SearchPlugin.java#L129

Whatever field sent will not make any difference. It will always search in the name field except email

guusdk commented 3 years ago

I believe that you're right in that this plugin does not follow the specification, but not quite right in the reason why.

When a search form is requested from the plugin, the following form is returned. From this, it can be deduced that this plugin offers a form with only one text input field, and a couple of boolean flags (that indicate to what properties the text input field should be checked).

It's definitely not what is being defined in XEP-0055, and offering a XEP-0055 compliant search would be good. At the same time, I worry about other clients that now depend on the existing behavior. We will need to find a solution that will work for both.

<iq to='search.example.org' id='BJN9L-54' type='get'>
  <query xmlns='jabber:iq:search'/>
</iq>
<iq type="result" id="BJN9L-54" from="search.example.org" to="test@example.org/one-tjvzu">
  <query xmlns="jabber:iq:search">
    <instructions>
      The following fields are available for searching. Wildcard (*) characters are allowed as part of the query.
    </instructions>
    <first/>
    <last/>
    <nick/>
    <email/>
    <x xmlns="jabber:x:data" type="form">
      <title>
        Advanced User Search
      </title>
      <instructions>
        The following fields are available for searching. Wildcard (*) characters are allowed as part of the query.
      </instructions>
      <field var="FORM_TYPE" type="hidden">
        <value>
          jabber:iq:search
        </value>
      </field>
      <field var="search" type="text-single" label="Search">
        <required/>
      </field>
      <field var="Username" type="boolean" label="Username">
        <value>
          1
        </value>
      </field>
      <field var="Name" type="boolean" label="Name">
        <value>
          1
        </value>
      </field>
      <field var="Email" type="boolean" label="Email">
        <value>
          1
        </value>
      </field>
    </x>
  </query>
</iq>