Closed Bug 1647252 Opened 4 years ago Closed 4 years ago

remove use of nsISAXXMLReader in XMPP

Categories

(Chat Core :: XMPP, task, P2)

Tracking

(thunderbird_esr78 wontfix, thunderbird88 wontfix)

RESOLVED FIXED
89 Branch
Tracking Status
thunderbird_esr78 --- wontfix
thunderbird88 --- wontfix

People

(Reporter: mkmelin, Assigned: rnons)

References

Details

Attachments

(2 files)

+++ This bug was initially created as a clone of Bug #1514669 +++

Bug 1447707 removed nsISAXXMLReader from m-c, and forked to commm-central in bug 1518552. This bug is to remove the nsISAXXMLReader usage from XMPP. See also bug 1514666

https://searchfox.org/comm-central/rev/b0826913e4dd6d1913c9974fcc4dcf89a29a6f6b/chat/protocols/xmpp/xmpp-xml.jsm#355

Curious what the reasoning is behind this? Is there a reasonable replacement?

It's the last use of nsISAXXMLReader in the whole code base except CalDAV, which should be reasonably straight forward to use normal DOM parsing). It's c++, so not web compatible.

I don't know what the reasonable replacement is - someone will have to investigate. Either it's reasonable to use DOM parsing instead, or maybe there's some JavaScript SAX library available we could use.

Thanks! One somewhat annoying thing with XMPP is that you don't get a full document for every message, so you do need some kind of incremental parsing. Not sure if that's doable with DOM parsing or not though!

DOMParser does not support incremental parsing. XHR should, but it's up to you to remove the old nodes from the DOM in order to avoid the DOM growing without bounds.

It looks like https://developer.mozilla.org/en-US/docs/Web/API/Streams_API could also provide a solution.

Assignee: nobody → remotenonsense

I tried and found DOMParser unsuitable for this. A few cases that doesn't work

  1. Tag is often not closed

    <?xml version='1.0'?><stream:stream ...><stream:features>...</stream:features>

  2. No xmlns:stream in stream:features. In a full document, xmlns can be inherited from the parent node, but if only one stanza is passed to DOMParser, it will error

    <stream:features>...</stream:features>

  3. No single root node and redundant closing tag

    <presence .../><presence .../></presence>

I can work around some of the problems but I think it's unreliable.

I found a JS lib https://www.npmjs.com/package/tag-soup, but haven't tried it yet. What I see is to use it we need to copy 10+ files into c-c, should I give it a try?

Could be worth a shot.

Status: NEW → ASSIGNED
Target Milestone: --- → 89 Branch

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/e16a0dcabced
Use sax-js to replace nsISAXXMLReader in xmpp-xml.jsm. r=clokep

Pushed by mkmelin@iki.fi: https://hg.mozilla.org/comm-central/rev/cfddb5081f1f add sax-js license notice (ISC). rs=me

(In reply to Pulsebot from comment #10)

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/cfddb5081f1f
add sax-js license notice (ISC). rs=me

The license file was already added in comment 9 at comm/chat/protocols/xmpp/lib/sax/LICENSE

Pushed by mkmelin@iki.fi: https://hg.mozilla.org/comm-central/rev/ce395a67fd73 followup - remove duplicated LICENSE file. rs=me

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/7bf3d75971bb
Remove unused nsISAXXMLReader. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Regressions: 1708695
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: