Skip to content

Commit

Permalink
Fix verification string computation.
Browse files Browse the repository at this point in the history
This is a fix for issue legoscia#37.

XEP-0115 describes how the presence iq elements presents
capabilities. In particular, capabilities are represented by a
verification string which consists of a hash of features and form data
fields that make up a capability list.

See, https://xmpp.org/extensions/xep-0115.html#ver-proc

The field list for a form consists of a "var" attribute with an
associated <value/> element.  It is not entirely clear from the XEP
how an empty <value/> element should be treated.  Unfortunately
jabber.el throws a 'wrong-type-argument for empty <values/>.

Here is an example form description sent from Psi+ that contains an
empty "os_version" value:

```xml
<x type="result" xmlns="jabber:x:data">
  <field type="hidden" var="FORM_TYPE">
    <value>urn:xmpp:dataforms:softwareinfo</value>
  </field>
  <field type="text-single" var="software">
    <value>Psi+</value>
  </field>
  <field type="text-single" var="software_version">
    <value>1.5.1650 (2023-06-10, 526ed0b8)</value>
  </field>
  <field type="text-single" var="os">
    <value>Debian GNU/Linux 11 (bullseye)</value>
  </field>
  <field type="text-single" var="os_version">
    <value/>
  </field>
</x>
```

Looking at the psi-plus-snapshots source suggests that an empty value
should be treated as an empty string.  Experimentation verifies that
this yields the same verification string that Psi+ sends with its
disco#info response.
  • Loading branch information
hdasch committed Mar 19, 2024
1 parent 633cb73 commit 8e4b72a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lisp/jabber-disco.el
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ obtained from `xml-parse-region'."
;; For each <value/> element, append the XML character
;; data, followed by the '<' character.
(dolist (value values)
(insert value "<"))))))))
(insert (or value "") "<"))))))))

;; 8. Ensure that S is encoded according to the UTF-8 encoding
;; (RFC 3269 [18]).
Expand Down

0 comments on commit 8e4b72a

Please sign in to comment.