Вопрос

I have sent Google Talk chats that are HTML in the way described by this question: How do you send HTML formatted messages over XMPP with Node.JS?

However, Gtalk seems to just interpret it as text. Does Gtalk accept HTML formatted messages?

To respond to the comment below: it could be either the client or the server that Google runs which is interpreting it incorrectly.

Это было полезно?

Решение

Yes, Google Talk accepts HTML formatted messages. However, as you observed, it disregards the formatted text and only shows the plain text. According to the XHTML-IM XEP, every HTML message must be accompanied by a plain text message for compatibility with clients that do not support HTML formatted messages.

When I send this example message to the Google Talk client on my Windows machine (using Psi's XML input console)...

<message to="test@gmail.com/Talk.v10445D0E8B1">
  <body>Wow, I&apos;m green with envy!</body>
  <html xmlns='http://jabber.org/protocol/xhtml-im'>
    <body xmlns='http://www.w3.org/1999/xhtml'>
      <p style='font-size:large'>
        <em>Wow</em>, I&apos;m <span style='color:green'>green</span>
        with <strong>envy</strong>!
      </p>
    </body>
  </html>
</message>

... I just see the text Wow, I'm green with envy!.

When I send the same message to my Psi client logged in to Google Talk, I receive...

<message from="test@jabber.org/Ben-PC" to="test@gmail.com">
<body>Wow, I'm green with envy!</body>
<html xmlns="http://jabber.org/protocol/xhtml-im">
<body xmlns="http://www.w3.org/1999/xhtml">
          <p style="font-size:large">
            <em>Wow</em>, I'm <span style="color:green">green</span>
            with <strong>envy</strong>!
          </p>
        </body>
      </html>
</message>

It was not stripped from the HTML, exactly as I expected (servers should not change the contents of messages). It shows as Psi showing formatted text, so it looks like Psi does support formatted text.

The way to test for capabilities is using Service Discovery. If I send...

<iq to='test@gmail.com/Talk.v10445D0E8B1' type='get'>
  <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>

... I receive...

<iq from="test@gmail.com/Talk.v10445D0E8B1" type="error" to="test@jabber.org/Ben-PC">
<query xmlns="http://jabber.org/protocol/disco#info"/>
<error type="cancel" code="501">
<feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
</error>
</iq>

... which means the Google Talk client does not support Service Discovery. We have to rely on the observation that HTML message text is ignored by the Google Talk client and server.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top