Skip to content

Commit

Permalink
fix(xmpp) unescape HTML entities in JSON messages
Browse files Browse the repository at this point in the history
Jigasi / Jitsi (desktop) seems to encode apostrophes like (&apos or &#39) for
instance.

This is notably visible in the subtitles.

Normalize it so it's plain UTF-8.
  • Loading branch information
saghul committed Jan 27, 2025
1 parent 54592e6 commit 8869b30
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion modules/xmpp/xmpp.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { safeJsonParse } from '@jitsi/js-utils/json';
import { getLogger } from '@jitsi/logger';
import $ from 'jquery';
import { unescape } from 'lodash-es';
import { $msg, Strophe } from 'strophe.js';
import 'strophejs-plugin-disco';

Expand Down Expand Up @@ -1019,7 +1020,9 @@ export default class XMPP extends Listenable {
}

try {
const json = safeJsonParse(jsonString);
// Note: we use `unescape` to also convert HTML entities to UTF-8 since
// Jigasi seems to encode them like that in some circumstances.
const json = safeJsonParse(unescape(jsonString));

// Handle non-exception-throwing cases:
// Neither JSON.parse(false) or JSON.parse(1234) throw errors,
Expand Down

0 comments on commit 8869b30

Please sign in to comment.